List of usage examples for com.vaadin.server ErrorEvent getThrowable
public Throwable getThrowable()
From source file:com.haulmont.cuba.web.exception.ExceptionHandlers.java
License:Apache License
/** * Delegates exception handling to registered handlers. * @param event error event generated by Vaadin *//*from w w w .jav a 2 s.c om*/ public void handle(ErrorEvent event) { for (ExceptionHandler handler : handlers) { if (handler.handle(event, app)) return; } WebWindowManager wm = app.getWindowManager(); if (wm != null) { for (GenericExceptionHandler handler : genericHandlers) { if (handler.handle(event.getThrowable(), wm)) return; } } defaultHandler.handle(event, app); }
From source file:com.haulmont.cuba.web.exception.InvalidValueExceptionHandler.java
License:Apache License
@Override public boolean handle(ErrorEvent event, App app) { boolean handled = super.handle(event, app); //noinspection ThrowableResultOfMethodCallIgnored if (handled && event.getThrowable() != null) { // Finds the original source of the error/exception AbstractComponent component = DefaultErrorHandler.findAbstractComponent(event); if (component != null) { component.markAsDirty();//from w w w. j a va 2 s . co m } if (component instanceof Component.Focusable) { ((Component.Focusable) component).focus(); } //noinspection ThrowableResultOfMethodCallIgnored if (event.getThrowable() instanceof Validator.InvalidValueException) { app.getAppUI().discardAccumulatedEvents(); } } return handled; }
From source file:com.haulmont.cuba.web.log.AppLog.java
License:Apache License
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") public void log(ErrorEvent event) { Throwable t = event.getThrowable(); if (t instanceof SilentException) return;/*from w w w . j av a 2 s .c o m*/ if (t instanceof Validator.InvalidValueException) return; if (t instanceof SocketException || ExceptionUtils.getRootCause(t) instanceof SocketException) { // Most likely client browser closed socket LogItem item = new LogItem(LogLevel.WARNING, "SocketException in CommunicationManager. Most likely client (browser) closed socket.", null); log(item); return; } // Support Tomcat 8 ClientAbortException if (StringUtils.contains(ExceptionUtils.getMessage(t), "ClientAbortException")) { // Most likely client browser closed socket LogItem item = new LogItem(LogLevel.WARNING, "ClientAbortException on write response to client. Most likely client (browser) closed socket.", null); log(item); return; } Throwable rootCause = ExceptionUtils.getRootCause(t); if (rootCause == null) rootCause = t; Logging annotation = rootCause.getClass().getAnnotation(Logging.class); Logging.Type loggingType = annotation == null ? Logging.Type.FULL : annotation.value(); if (loggingType == Logging.Type.NONE) return; // Finds the original source of the error/exception AbstractComponent component = DefaultErrorHandler.findAbstractComponent(event); StringBuilder msg = new StringBuilder(); msg.append("Exception"); if (component != null) msg.append(" in ").append(component.getClass().getName()); msg.append(": "); if (loggingType == Logging.Type.BRIEF) { error(msg + rootCause.toString()); } else { LogItem item = new LogItem(LogLevel.ERROR, msg.toString(), t); log(item); } }
From source file:com.klwork.explorer.web.MyNavigationUI.java
License:Apache License
/** * Exception on action/* ww w. j a va 2s . c o m*/ */ @Override public void error(com.vaadin.server.ErrorEvent event) { // connector event if (event.getThrowable().getCause() instanceof IllegalArgumentException) { IllegalArgumentException exception = (IllegalArgumentException) event.getThrowable().getCause(); Notification.show(exception.getMessage(), Notification.Type.ERROR_MESSAGE); // Cleanup view. Now Vaadin ignores errors and always shows the view. :-( // since beta10 setContent(null); return; } // Error on page load. Now it doesn't work. User sees standard error page. if (event.getThrowable() instanceof IllegalArgumentException) { IllegalArgumentException exception = (IllegalArgumentException) event.getThrowable(); Label label = new Label(exception.getMessage()); label.setWidth(-1, Unit.PERCENTAGE); Link goToMain = new Link("Go to main", new ExternalResource("/")); VerticalLayout layout = new VerticalLayout(); layout.addComponent(label); layout.addComponent(goToMain); layout.setComponentAlignment(label, Alignment.MIDDLE_CENTER); layout.setComponentAlignment(goToMain, Alignment.MIDDLE_CENTER); VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setSizeFull(); mainLayout.addComponent(layout); mainLayout.setComponentAlignment(layout, Alignment.MIDDLE_CENTER); setContent(mainLayout); Notification.show(exception.getMessage(), Notification.Type.ERROR_MESSAGE); return; } DefaultErrorHandler.doDefault(event); }
From source file:com.lst.deploymentautomation.vaadin.core.LspsUI.java
License:Open Source License
@Override public void error(com.vaadin.server.ErrorEvent event) { handleError(event.getThrowable()); }
From source file:com.mycollab.mobile.MobileApplication.java
License:Open Source License
@Override protected void init(VaadinRequest request) { OfflineMode offlineMode = new OfflineMode(); offlineMode.extend(this); // Maintain the session when the browser app closes offlineMode.setPersistentSessionCookie(true); // Define the timeout in secs to wait when a server // request is sent before falling back to offline mode offlineMode.setOfflineModeTimeout(15); VaadinSession.getCurrent().setErrorHandler(new DefaultErrorHandler() { private static final long serialVersionUID = 1L; @Override// ww w . ja v a2 s . c o m public void error(com.vaadin.server.ErrorEvent event) { Throwable e = event.getThrowable(); IgnoreException ignoreException = (IgnoreException) getExceptionType(e, IgnoreException.class); if (ignoreException != null) { return; } SessionExpireException sessionExpireException = (SessionExpireException) getExceptionType(e, SessionExpireException.class); if (sessionExpireException != null) { Page.getCurrent().getJavaScript().execute("window.location.reload();"); return; } UserInvalidInputException invalidException = (UserInvalidInputException) getExceptionType(e, UserInvalidInputException.class); if (invalidException != null) { NotificationUtil.showWarningNotification(UserUIContext .getMessage(GenericI18Enum.ERROR_USER_INPUT_MESSAGE, invalidException.getMessage())); } else { UsageExceedBillingPlanException usageBillingException = (UsageExceedBillingPlanException) getExceptionType( e, UsageExceedBillingPlanException.class); if (usageBillingException != null) { if (UserUIContext.isAdmin()) { ConfirmDialog.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.EXCEED_BILLING_PLAN_MSG_FOR_ADMIN), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), dialog -> { if (dialog.isConfirmed()) { Collection<Window> windows = UI.getCurrent().getWindows(); for (Window window : windows) { window.close(); } EventBusFactory.getInstance().post(new ShellEvent.GotoUserAccountModule( this, new String[] { "billing" })); } }); } else { NotificationUtil.showErrorNotification( UserUIContext.getMessage(GenericI18Enum.EXCEED_BILLING_PLAN_MSG_FOR_USER)); } } else { LOG.error("Error", e); NotificationUtil.showErrorNotification( UserUIContext.getMessage(GenericI18Enum.ERROR_USER_NOTICE_INFORMATION_MESSAGE)); } } } }); setCurrentFragmentUrl(this.getPage().getUriFragment()); currentContext = new UserUIContext(); postSetupApp(request); final NavigationManager manager = new NavigationManager(); setContent(manager); registerControllers(manager); ThemeManager.loadMobileTheme(MyCollabUI.getAccountId()); getPage().addUriFragmentChangedListener(new UriFragmentChangedListener() { private static final long serialVersionUID = -6410955178515535406L; @Override public void uriFragmentChanged(UriFragmentChangedEvent event) { setCurrentFragmentUrl(event.getUriFragment()); enter(event.getUriFragment()); } }); detectAutoLogin(); }
From source file:com.mycollab.web.DesktopApplication.java
License:Open Source License
@Override protected void init(final VaadinRequest request) { broadcastReceiverService = AppContextUtil.getSpringBean(BroadcastReceiverService.class); if (SiteConfiguration.getPullMethod() == SiteConfiguration.PullMethod.push) { getPushConfiguration().setPushMode(PushMode.MANUAL); }//w w w. j a va2 s.com VaadinSession.getCurrent().setErrorHandler(new DefaultErrorHandler() { private static final long serialVersionUID = 1L; @Override public void error(com.vaadin.server.ErrorEvent event) { Throwable e = event.getThrowable(); handleException(request, e); } }); setCurrentFragmentUrl(this.getPage().getUriFragment()); currentContext = new UserUIContext(); postSetupApp(request); EventBusFactory.getInstance().register(new ShellErrorHandler()); mainWindowContainer = new MainWindowContainer(); this.setContent(mainWindowContainer); getPage().setTitle("MyCollab - Online project management"); getPage().addUriFragmentChangedListener( uriFragmentChangedEvent -> enter(uriFragmentChangedEvent.getUriFragment())); String userAgent = request.getHeader("user-agent"); if (isInNotSupportedBrowserList(userAgent.toLowerCase())) { NotificationUtil.showWarningNotification(UserUIContext.getMessage(ErrorI18nEnum.BROWSER_OUT_UP_DATE)); } }
From source file:com.peergreen.webconsole.core.exception.VaadinErrorHandler.java
License:Open Source License
@Override public void error(ErrorEvent event) { LOGGER.error(event.getThrowable().getMessage(), event.getThrowable()); }
From source file:de.gedoplan.webclients.vaadin.base.ErrorHandler.java
@Override public void error(ErrorEvent event) { Throwable throwable = findRelevantThrowable(event.getThrowable()); if (throwable instanceof EJBAccessException) { Notification.show(Messages.notallowed.value(), Notification.Type.ERROR_MESSAGE); logger.warning("Unberechtigter Zugriff verhindert!"); } else {// w w w . j ava 2 s .co m logger.log(Level.SEVERE, "Es ist ein interner Fehler aufgetreten", throwable); Notification.show("Es ist ein interner Fehler aufgetreten", Notification.Type.ERROR_MESSAGE); } }
From source file:de.metas.procurement.webui.server.AbstractErrorHandler.java
License:Open Source License
@Override public final void error(final ErrorEvent event) { ////w w w .ja v a 2s. c o m // Extract the relevant exception Throwable t = event.getThrowable(); if (t instanceof SocketException) { // Most likely client browser closed socket logger.info("SocketException in CommunicationManager. Most likely client (browser) closed socket."); return; } t = DefaultErrorHandler.findRelevantThrowable(t); // // Create error message final ErrorMessage errorMessage = createErrorMessage(t); // // Display it displayError(errorMessage, event); // also print the error on console logger.error("", t); }