List of usage examples for com.vaadin.server ErrorEvent getThrowable
public Throwable getThrowable()
From source file:annis.gui.AnnisUI.java
License:Apache License
@Override public void error(com.vaadin.server.ErrorEvent event) { log.error("Unknown error in some component: " + event.getThrowable().getLocalizedMessage(), event.getThrowable());//w w w . ja v a 2 s . c o m // get the source throwable (thus the one that triggered the error) Throwable source = event.getThrowable(); if (source != null) { while (source.getCause() != null) { source = source.getCause(); } ExceptionDialog.show(source); } }
From source file:by.bigvova.MainUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { EventBus.register(this); getPage().setTitle("FoodNote"); UI.getCurrent().setLocale(Locale.forLanguageTag("ru-RU")); // Let's register a custom error handler to make the 'access denied' messages a bit friendlier. setErrorHandler(new DefaultErrorHandler() { @Override/* w w w .j a v a 2s.c o m*/ public void error(com.vaadin.server.ErrorEvent event) { if (SecurityExceptionUtils.isAccessDeniedException(event.getThrowable())) { Notification.show("Sorry, you don't have access to do that."); } else { super.error(event); } } }); HorizontalLayout layout = new HorizontalLayout(); layout.setSizeFull(); // By adding a security item filter, only views that are accessible to the user will show up in the side bar. sideBar.setItemFilter(new VaadinSecurityItemFilter(vaadinSecurity)); sideBar.setHeader(new CssLayout() { { Label header = new Label("<span>Food</span>Note", ContentMode.HTML); header.setWidth(100, Unit.PERCENTAGE); header.setHeightUndefined(); addComponent(header); addComponent(buildUserMenu()); } }); sideBar.getHeader().setStyleName("branding"); layout.addComponent(sideBar); CssLayout viewContainer = new CssLayout(); viewContainer.setSizeFull(); layout.addComponent(viewContainer); layout.setExpandRatio(viewContainer, 1f); Navigator navigator = new Navigator(this, viewContainer); // Without an AccessDeniedView, the view provider would act like the restricted views did not exist at all. springViewProvider.setAccessDeniedViewClass(AccessDeniedView.class); navigator.addProvider(springViewProvider); navigator.setErrorView(ErrorView.class); navigator.navigateTo(navigator.getState()); setContent(layout); // Call this here because the Navigator must have been configured before the Side Bar can be attached to a UI. }
From source file:com.esofthead.mycollab.mobile.MobileApplication.java
License:Open Source License
@Override protected void init(VaadinRequest request) { LOG.debug("Init mycollab mobile application {}", this.toString()); VaadinSession.getCurrent().setErrorHandler(new DefaultErrorHandler() { private static final long serialVersionUID = 1L; @Override/*from w w w.j a v a2s . co 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(AppContext .getMessage(GenericI18Enum.ERROR_USER_INPUT_MESSAGE, invalidException.getMessage())); } else { UsageExceedBillingPlanException usageBillingException = (UsageExceedBillingPlanException) getExceptionType( e, UsageExceedBillingPlanException.class); if (usageBillingException != null) { if (AppContext.isAdmin()) { ConfirmDialog.show(UI.getCurrent(), AppContext.getMessage(GenericI18Enum.EXCEED_BILLING_PLAN_MSG_FOR_ADMIN), AppContext.getMessage(GenericI18Enum.BUTTON_YES), AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.CloseListener() { private static final long serialVersionUID = 1L; @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { Collection<Window> windowsList = UI.getCurrent().getWindows(); for (Window window : windowsList) { window.close(); } EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" })); } } }); } else { NotificationUtil.showErrorNotification( AppContext.getMessage(GenericI18Enum.EXCEED_BILLING_PLAN_MSG_FOR_USER)); } } else { LOG.error("Error", e); NotificationUtil.showErrorNotification( AppContext.getMessage(GenericI18Enum.ERROR_USER_NOTICE_INFORMATION_MESSAGE)); } } } }); initialUrl = this.getPage().getUriFragment(); MyCollabSession.putVariable(CURRENT_APP, this); currentContext = new AppContext(); postSetupApp(request); try { currentContext.initDomain(initialSubDomain); } catch (Exception e) { // TODO: show content notice user there is no existing domain return; } this.getLoadingIndicatorConfiguration().setFirstDelay(0); this.getLoadingIndicatorConfiguration().setSecondDelay(300); this.getLoadingIndicatorConfiguration().setThirdDelay(500); final MobileNavigationManager manager = new MobileNavigationManager(); manager.addNavigationListener(new NavigationManager.NavigationListener() { private static final long serialVersionUID = -2317588983851761998L; @SuppressWarnings("unchecked") @Override public void navigate(NavigationEvent event) { NavigationManager currentNavigator = (NavigationManager) event.getSource(); if (event.getDirection() == Direction.BACK) { Component nextComponent = currentNavigator.getNextComponent(); ViewState currentState = MobileHistoryViewManager.peak(); if (!(currentState instanceof NullViewState) && currentState.getPresenter().getView().equals(nextComponent)) { ViewState viewState = MobileHistoryViewManager.pop(); while (!(viewState instanceof NullViewState)) { if (viewState.getPresenter().getView().equals(currentNavigator.getCurrentComponent())) { viewState.getPresenter().go(viewState.getContainer(), viewState.getParams()); break; } viewState = MobileHistoryViewManager.pop(false); } } if (nextComponent instanceof NavigationView) { ((NavigationView) nextComponent).setPreviousComponent(null); } currentNavigator.removeComponent(nextComponent); currentNavigator.getState().setNextComponent(null); } } }); setContent(manager); registerControllers(manager); getPage().addUriFragmentChangedListener(new UriFragmentChangedListener() { private static final long serialVersionUID = -6410955178515535406L; @Override public void uriFragmentChanged(UriFragmentChangedEvent event) { setInitialUrl(event.getUriFragment()); enter(event.getUriFragment()); } }); enter(initialUrl); }
From source file:com.esofthead.mycollab.web.DesktopApplication.java
License:Open Source License
@Override protected void init(VaadinRequest request) { LOG.debug("Init mycollab application {} associate with session {}", this.toString(), VaadinSession.getCurrent()); LOG.debug("Register default error handler"); VaadinSession.getCurrent().setErrorHandler(new DefaultErrorHandler() { private static final long serialVersionUID = 1L; @Override/*from w ww .java 2 s.c o m*/ public void error(com.vaadin.server.ErrorEvent event) { Throwable e = event.getThrowable(); handleException(e); } }); initialUrl = this.getPage().getUriFragment(); MyCollabSession.putVariable(CURRENT_APP, this); currentContext = new AppContext(); postSetupApp(request); try { currentContext.initDomain(initialSubDomain); } catch (SubDomainNotExistException e) { this.setContent(new NoSubDomainExistedWindow(initialSubDomain)); return; } mainWindowContainer = new MainWindowContainer(); this.setContent(mainWindowContainer); getPage().addUriFragmentChangedListener(new UriFragmentChangedListener() { private static final long serialVersionUID = 1L; @Override public void uriFragmentChanged(UriFragmentChangedEvent event) { enter(event.getUriFragment()); } }); EventBusFactory.getInstance().register(new ShellErrorHandler()); String userAgent = request.getHeader("user-agent"); if (isInNotSupportedBrowserList(userAgent.toLowerCase())) { NotificationUtil .showWarningNotification("Your browser is out of date. Some features of MyCollab will not" + " behave correctly. You should upgrade to the newer browser."); } }
From source file:com.foc.vaadin.FocWebApplication.java
License:Apache License
public void initialize(VaadinRequest vaadinRequest, ServletContext servletContext, HttpSession httpSession, boolean webServicesOnly) { // setTheme(FocVaadinTheme.THEME_NAME); // Page.getCurrent().setUriFragment("01barmaja"); Globals.logString("FocWebApplication.init 111"); setErrorHandler(new DefaultErrorHandler() { @Override//from w ww. ja v a2s . co m public void error(com.vaadin.server.ErrorEvent event) { Globals.logString("Error - 1"); Throwable throwable = event != null ? event.getThrowable() : null; Globals.logString("Error - 2"); if (throwable != null && throwable instanceof Exception) { Globals.logString("Error - 3"); Globals.logException((Exception) throwable); Globals.logString("Error - 4"); } // Do the default error handling (optional) doDefault(event); } }); String userAgent = vaadinRequest != null ? vaadinRequest.getHeader("User-Agent") : null; isMobile = Utils.isMobile(userAgent); Globals.logString("FocWebApplication.init 2"); // isMobile = Globals.isTouchDevice(); String path = vaadinRequest != null ? vaadinRequest.getPathInfo() : null; Globals.logString("FocWebApplication.init 3"); if (path != null && !path.isEmpty() && path.length() > 1) { path = path.substring(1); isMobile = path.toLowerCase().trim().equals("m"); } Globals.logString("FocWebApplication.init 4"); addStyleName("focMainWindow"); Globals.logString("FocWebApplication.init 5"); // FocWebApplication.setInstanceForThread(this); setSessionIfEmpty(httpSession); Globals.logString("FocWebApplication.init 6"); startApplicationServer(servletContext, webServicesOnly); Globals.logString("FocWebApplication.init 7"); FocWebServer focWebServer = FocWebServer.getInstance(); if (focWebServer == null) { Globals.logString("FocWebApplication.init 8 - SERVER IS NULL"); } else { Globals.logString("FocWebApplication.init 8 - SERVER OK"); } focWebServer.addApplication(this); Globals.logString("FocWebApplication.init 9"); }
From source file:com.github.daytron.generalerrorhandling.CustomErrorHandler.java
@Override public void error(ErrorEvent event) { Throwable throwable = event.getThrowable(); errorbar.displayyError(throwable); }
From source file:com.hack23.cia.web.impl.ui.application.UiInstanceErrorHandler.java
License:Apache License
@Override public void error(final ErrorEvent event) { if (event.getThrowable() instanceof AccessDeniedException) { final AccessDeniedException accessDeniedException = (AccessDeniedException) event.getThrowable(); Notification.show(accessDeniedException.getMessage(), Notification.Type.ERROR_MESSAGE); ui.getNavigator().navigateTo(CommonsViews.MAIN_VIEW_NAME); return;/* w w w .ja va 2 s. c o m*/ } else if (event.getThrowable().getCause() != null && event.getThrowable().getCause().getCause() != null && event.getThrowable().getCause().getCause().getCause() instanceof AccessDeniedException) { final AccessDeniedException accessDeniedException = (AccessDeniedException) event.getThrowable() .getCause().getCause().getCause(); Notification.show(accessDeniedException.getMessage(), Notification.Type.ERROR_MESSAGE); ui.getNavigator().navigateTo(CommonsViews.MAIN_VIEW_NAME); return; } else { LOGGER.warn(LOG_WARN_VAADIN_ERROR, event.getThrowable()); } }
From source file:com.haulmont.cuba.web.AppUI.java
License:Apache License
@Override public void error(com.vaadin.server.ErrorEvent event) { try {/*ww w .j av a 2 s . c om*/ app.getExceptionHandlers().handle(event); app.getAppLog().log(event); } catch (Throwable e) { //noinspection ThrowableResultOfMethodCallIgnored log.error("Error handling exception\nOriginal exception:\n{}\nException in handlers:\n{}", ExceptionUtils.getStackTrace(event.getThrowable()), ExceptionUtils.getStackTrace(e)); } }
From source file:com.haulmont.cuba.web.exception.AbstractExceptionHandler.java
License:Apache License
@Override public boolean handle(ErrorEvent event, App app) { Throwable exception = event.getThrowable(); //noinspection unchecked List<Throwable> list = ExceptionUtils.getThrowableList(exception); for (Throwable throwable : list) { if (classNames.contains(throwable.getClass().getName()) && canHandle(throwable.getClass().getName(), throwable.getMessage(), throwable)) { doHandle(app, throwable.getClass().getName(), throwable.getMessage(), throwable); return true; }//w w w . j a va 2s . co m if (throwable instanceof RemoteException) { RemoteException remoteException = (RemoteException) throwable; for (RemoteException.Cause cause : remoteException.getCauses()) { if (classNames.contains(cause.getClassName()) && canHandle(cause.getClassName(), cause.getMessage(), cause.getThrowable())) { doHandle(app, cause.getClassName(), cause.getMessage(), cause.getThrowable()); return true; } } } } return false; }
From source file:com.haulmont.cuba.web.exception.DefaultExceptionHandler.java
License:Apache License
@Override public boolean handle(ErrorEvent event, App app) { // Copied from com.vaadin.server.DefaultErrorHandler.doDefault() //noinspection ThrowableResultOfMethodCallIgnored Throwable t = event.getThrowable(); //noinspection ThrowableResultOfMethodCallIgnored if (t instanceof SocketException || ExceptionUtils.getRootCause(t) instanceof SocketException) { // Most likely client browser closed socket return true; }/*from w w w . ja va2 s . c o m*/ // Support Tomcat 8 ClientAbortException if (StringUtils.contains(ExceptionUtils.getMessage(t), "ClientAbortException")) { // Most likely client browser closed socket return true; } AppUI ui = AppUI.getCurrent(); if (ui == null) { // there is no UI, just add error to log return true; } if (t != null) { if (app.getConnection().getSession() != null) { showDialog(app, t); } else { showNotification(app, t); } } return true; }