List of usage examples for com.vaadin.server ErrorEvent getThrowable
public Throwable getThrowable()
From source file:org.jumpmind.vaadin.ui.common.AbstractSpringUI.java
License:Open Source License
@Override protected void init(VaadinRequest request) { setErrorHandler(new DefaultErrorHandler() { private static final long serialVersionUID = 1L; @Override/*from w w w . ja va 2 s . c o m*/ public void error(com.vaadin.server.ErrorEvent event) { Throwable ex = event.getThrowable(); CommonUiUtils.notify(ex); if (ex != null) { log.error(ex.getMessage(), ex); } else { log.error("An unexpected error occurred"); } } }); VaadinSession.getCurrent().setConverterFactory(new DefaultConverterFactory() { private static final long serialVersionUID = 1L; @Override protected Converter<Date, ?> createDateConverter(Class<?> sourceType) { return super.createDateConverter(sourceType); } protected Converter<String, ?> createStringConverter(Class<?> sourceType) { if (Double.class.isAssignableFrom(sourceType)) { return new StringToDoubleConverter(); } else if (Float.class.isAssignableFrom(sourceType)) { return new StringToFloatConverter(); } else if (Integer.class.isAssignableFrom(sourceType)) { return new StringToIntegerConverter() { private static final long serialVersionUID = 1L; @Override protected NumberFormat getFormat(Locale locale) { NumberFormat format = super.getFormat(locale); format.setGroupingUsed(false); return format; } }; } else if (Long.class.isAssignableFrom(sourceType)) { return new StringToLongConverter() { private static final long serialVersionUID = 1L; @Override protected NumberFormat getFormat(Locale locale) { NumberFormat format = super.getFormat(locale); format.setGroupingUsed(false); return format; } }; } else if (BigDecimal.class.isAssignableFrom(sourceType)) { return new StringToBigDecimalConverter(); } else if (Boolean.class.isAssignableFrom(sourceType)) { return new StringToBooleanConverter(); } else if (Date.class.isAssignableFrom(sourceType)) { return new StringToDateConverter(); } else { return null; } } }); Responsive.makeResponsive(this); }
From source file:org.lunifera.ecview.vaadin.ide.preview.web.EcviewMobilePreviewUI.java
License:Open Source License
@Override protected void init(VaadinRequest request) { setErrorHandler(new ErrorHandler() { @Override/*from w w w . j a v a 2s. c o m*/ public void error(com.vaadin.server.ErrorEvent event) { if (EcviewMobilePreviewUI.this.isClosing() || !EcviewMobilePreviewUI.this.isAttached()) { return; } UI.setCurrent(EcviewMobilePreviewUI.this); disconnectAndClose(event.getThrowable()); } }); if (!Activator.getMobilePreviewHandler().setPreviewUI(this)) { worksWithCopy = true; } setStyleName(Reindeer.LAYOUT_BLUE); VaadinObservables.getRealm(getUI()); layout = new CssLayout(); layout.setSizeFull(); setContent(layout); modelChanged(); }
From source file:org.lunifera.ecview.vaadin.ide.preview.web.EcviewPreviewUI.java
License:Open Source License
@Override protected void init(VaadinRequest request) { setErrorHandler(new ErrorHandler() { @Override/* w w w . j a v a 2 s . co m*/ public void error(com.vaadin.server.ErrorEvent event) { if (EcviewPreviewUI.this.isClosing() || !EcviewPreviewUI.this.isAttached()) { return; } UI.setCurrent(EcviewPreviewUI.this); disconnectAndClose(event.getThrowable()); } }); if (!Activator.getIDEPreviewHandler().setPreviewUI(this)) { worksWithCopy = true; } setStyleName(Reindeer.LAYOUT_BLUE); VaadinObservables.getRealm(getUI()); layout = new CssLayout(); layout.setSizeFull(); setContent(layout); modelChanged(); }
From source file:org.opencms.ui.CmsVaadinErrorHandler.java
License:Open Source License
/** * @see com.vaadin.server.DefaultErrorHandler#error(com.vaadin.server.ErrorEvent) *//*from w w w. j a v a2 s. c om*/ @Override public void error(ErrorEvent event) { super.error(event); if (m_ui != null) { m_ui.onError(); } Throwable throwable = event.getThrowable(); if (!(throwable instanceof SocketException)) { LOG.error(throwable.getLocalizedMessage(), throwable); } }
From source file:org.opennms.features.topology.app.internal.TopologyUI.java
License:Open Source License
private void setupErrorHandler() { setErrorHandler(new DefaultErrorHandler() { @Override/*from www. j av a 2 s.c o m*/ public void error(com.vaadin.server.ErrorEvent event) { Notification.show("An Exception Occurred: see karaf.log", Notification.Type.TRAY_NOTIFICATION); LOG.warn("An Exception Occurred: in the TopologyUI", event.getThrowable()); } }); }
From source file:org.vaadin.spring.samples.security.managed.SingleSecuredUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { getPage().setTitle("Vaadin Managed Security Demo"); // Let's register a custom error handler to make the 'access denied' messages a bit friendlier. setErrorHandler(new DefaultErrorHandler() { @Override/*from ww w .jav a 2s . co 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); } } }); if (vaadinSecurity.isAuthenticated()) { showMainScreen(); } else { showLoginScreen(request.getParameter("goodbye") != null); } }
From source file:org.vaadin.spring.samples.security.shared.MainUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { getPage().setTitle("Vaadin Shared Security Demo"); // Let's register a custom error handler to make the 'access denied' messages a bit friendlier. setErrorHandler(new DefaultErrorHandler() { @Override/* ww w. ja v a 2 s. com*/ 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)); 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:pl.exsio.frameset.vaadin.ui.FramesetUI.java
License:Open Source License
protected void setProductionErrorHandlerIfAppropriate() { DeploymentConfiguration conf = getSession().getConfiguration(); if (conf.isProductionMode()) { this.setErrorHandler(new ErrorHandler() { @Override// ww w . j a va2 s. co m public void error(com.vaadin.server.ErrorEvent event) { Notification.show(event.getThrowable().getMessage(), Notification.Type.TRAY_NOTIFICATION); } }); } }
From source file:uk.co.q3c.v7.base.shiro.V7ErrorHandler.java
License:Apache License
@Override public void error(ErrorEvent event) { Throwable originalError = event.getThrowable(); // handle an unauthorised access attempt int unauthorised = ExceptionUtils.indexOfThrowable(originalError, UnauthorizedException.class); if (unauthorised >= 0) { authorisationHandler.invoke();// w w w.j a v a 2s .c o m return; } // handle an unauthenticated access attempt int unauthenticated = ExceptionUtils.indexOfThrowable(originalError, UnauthenticatedException.class); if (unauthenticated >= 0) { authenticationHandler.invoke(); return; } // some other exception doDefault(event); }
From source file:uk.q3c.krail.core.shiro.KrailErrorHandler.java
License:Apache License
@Override public void error(ErrorEvent event) { Throwable originalError = event.getThrowable(); // handle an attempt to navigate to an invalid page int invalidURI = ExceptionUtils.indexOfThrowable(originalError, InvalidURIException.class); if (invalidURI >= 0) { InvalidURIException e = (InvalidURIException) ExceptionUtils.getThrowables(originalError)[invalidURI]; invalidUriHandler.invoke(e);/* w ww . ja va 2s . co m*/ return; } // handle an unauthorised access attempt int unauthorised = ExceptionUtils.indexOfThrowable(originalError, UnauthorizedException.class); if (unauthorised >= 0) { authorisationHandler.invoke(); return; } // handle an unauthenticated access attempt int unauthenticated = ExceptionUtils.indexOfThrowable(originalError, UnauthenticatedException.class); if (unauthenticated >= 0) { authenticationHandler.invoke(); return; } int notAUser = ExceptionUtils.indexOfThrowable(originalError, NotAUserException.class); if (notAUser >= 0) { notAUserExceptionHandler.invoke(); return; } int notAGuest = ExceptionUtils.indexOfThrowable(originalError, NotAGuestException.class); if (notAGuest >= 0) { notAGuestExceptionHandler.invoke(); return; } // catch-all handle an unauthorised access attempt, exceptions are not always thrown at more specific level unauthorised = ExceptionUtils.indexOfThrowable(originalError, AuthorizationException.class); if (unauthorised >= 0) { authorisationHandler.invoke(); return; } // no handler identified, display the exception on the error page int loginEmpty = ExceptionUtils.indexOfThrowable(originalError, LoginFormException.class); if (loginEmpty > 0) { LoginFormException lfe = (LoginFormException) ExceptionUtils.getThrowableList(originalError) .get(loginEmpty); userNotifier.notifyWarning(lfe.getMsgKey(), lfe.getParams()); return; } navigator.error(event.getThrowable()); }