List of usage examples for com.vaadin.server ErrorEvent getThrowable
public Throwable getThrowable()
From source file:de.metas.ui.web.vaadin.window.view.AbstractView.java
License:Open Source License
private void showError(final ErrorEvent event) { final Throwable ex = event.getThrowable(); logger.warn("Got error", ex); final String errorMessage = Throwables.getRootCause(ex).getLocalizedMessage(); showError(errorMessage);/*from w w w.j a va 2 s. co m*/ }
From source file:de.symeda.sormas.ui.SormasErrorHandler.java
License:Open Source License
public static void handleError(ErrorEvent event) { final Throwable t = event.getThrowable(); if (t instanceof SocketException) { // Most likely client browser closed socket logger.info(/* w w w . j a v a 2s . c om*/ "SocketException in CommunicationManager." + " Most likely client (browser) closed socket."); return; } ErrorMessage errorMessage = getErrorMessageForException(t); if (t != null) { // log the error or warning if (errorMessage instanceof SystemError) { logger.error(t.getMessage(), t); } else { logger.warn(t.getMessage(), t); } } // finds the original source of the error/exception AbstractComponent component = DefaultErrorHandler.findAbstractComponent(event); if (errorMessage != null && component != null) { // Shows the error in AbstractComponent if (errorMessage instanceof SystemError) { Notification.show( I18nProperties.getString(Strings.errorOccurred, I18nProperties.getString(Strings.errorOccurred)), I18nProperties.getString(Strings.errorWasReported), Notification.Type.ERROR_MESSAGE); } else { // to prevent the original message from appearing, if necessary if (component instanceof AbstractField<?>) { ((AbstractField<?>) component).setCurrentBufferedSourceException(null); } Notification notification = new Notification( I18nProperties.getString(Strings.errorProblemOccurred, I18nProperties.getString(Strings.errorProblemOccurred)), errorMessage.getFormattedHtmlMessage(), Notification.Type.WARNING_MESSAGE, true); notification.setDelayMsec(-1); notification.show(Page.getCurrent()); component.setComponentError(errorMessage); } } }
From source file:de.unioninvestment.eai.portal.portlet.crud.CrudErrorHandler.java
License:Apache License
@Override public void error(ErrorEvent event) { Throwable throwable = event.getThrowable(); LOGGER.error("Internal error", StackTraceUtils.deepSanitize(throwable)); if (Page.getCurrent() != null) { displayRootCauseAsErrorNotification(throwable); }//from ww w .j a v a2 s. c o m }
From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultTableView.java
License:Apache License
/** * Konfiguriert einen ErrorHandler, der Fehler mglichst lesbar als * Notification anzeigt.//from w w w .j ava2 s .c o m */ @SuppressWarnings("serial") protected void setupErrorHandling() { table.setErrorHandler(new CrudErrorHandler() { @Override public void error(com.vaadin.server.ErrorEvent event) { Throwable throwable = event.getThrowable(); if (throwable instanceof SourceException) { onError(throwable); } else { super.error(event); } } }); }
From source file:edu.kit.dama.ui.admin.AdminUIMainView.java
License:Apache License
private void doBasicSetup() { //configure SiMon try {/*from w w w . jav a 2 s . c om*/ String path = DataManagerSettings.getSingleton() .getStringProperty(DataManagerSettings.SIMON_CONFIG_LOCATION_ID, null); if (path == null || !new File(path).exists()) { throw new ConfigurationException("Configuration element '" + DataManagerSettings.SIMON_CONFIG_LOCATION_ID + "' is not set or not a valid directory."); } File configLocation = new File(path); SimonConfigurator.getSingleton().setConfigLocation(configLocation); } catch (ConfigurationException ex) { LOGGER.error("Failed to initialize SimpleMonitoring", ex); } //set error handler in order to catch unhandled exceptions UI.getCurrent().setErrorHandler(new DefaultErrorHandler() { @Override public void error(com.vaadin.server.ErrorEvent event) { String cause = "<h3>An unexpected error has occured. Please reload the page.<br/>" + "If the error persists, please contact an administrator.</h3>"; Label errorLabel = new Label(cause, ContentMode.HTML); errorLabel.setDescription(StackTraceUtil.getCustomStackTrace(event.getThrowable(), false)); LOGGER.error("An unhandled exception has occured!", event.getThrowable()); // Display the error message in a custom fashion mainLayout.addComponent(errorLabel, 0); // Do the default error handling (optional) doDefault(event); } }); }
From source file:fr.amapj.view.engine.ui.AmapUI.java
License:Open Source License
/** * Gestion des erreurs// www . j av a2s .co m */ private void setErrorHandling() { setErrorHandler(new DefaultErrorHandler() { @Override public void error(com.vaadin.server.ErrorEvent event) { Throwable t = event.getThrowable(); ErrorPopup.open(t); } }); }
From source file:info.magnolia.ui.admincentral.AdmincentralErrorHandler.java
License:Open Source License
@Override public void error(ErrorEvent event) { log.error(DEFAULT_MESSAGE, event.getThrowable()); Message message = getErrorMessage(event.getThrowable()); messagesManager.sendLocalMessage(message); }
From source file:org.eclipse.hawkbit.ui.components.HawkbitUIErrorHandler.java
License:Open Source License
private static Throwable getRootExceptionFrom(final ErrorEvent event) { return getRootCauseOf(event.getThrowable()); }
From source file:org.freakz.hokan_ng_springboot.bot.SingleSecuredUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { uiServiceMessageHandler.register(this); getPage().setTitle("Hokan"); // Let's register a custom error handler to make the 'access denied' messages a bit friendlier. setErrorHandler(new DefaultErrorHandler() { @Override//from w w w .j av 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); } } }); if (vaadinSecurity.isAuthenticated()) { showMainScreen(); } else { showLoginScreen(request.getParameter("goodbye") != null); } }
From source file:org.jumpmind.metl.ui.init.AppUI.java
License:Open Source License
@SuppressWarnings("serial") @Override//w ww . ja va 2 s.c o m protected void init(VaadinRequest request) { WebApplicationContext ctx = getWebApplicationContext(); backgroundRefresherService = ctx.getBean(BackgroundRefresherService.class); backgroundRefresherService.init(this); UI.getCurrent().setErrorHandler(new DefaultErrorHandler() { public void error(com.vaadin.server.ErrorEvent event) { String intro = "Exception of type <b>"; String message = ""; for (Throwable t = event.getThrowable(); t != null; t = t.getCause()) { if (t.getCause() == null) { intro += t.getClass().getName() + "</b> with the following message:<br/><br/>"; message = t.getMessage(); } } ErrorWindow window = new ErrorWindow(intro, message); window.show(); Throwable ex = event.getThrowable(); 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); ApplicationContext appCtx = ctx.getBean(ApplicationContext.class); if (appCtx.getConfigurationService().isUserLoginEnabled()) { LoginDialog login = new LoginDialog(appCtx, this); UI.getCurrent().addWindow(login); } else { User user = appCtx.getConfigurationService().findUserByLoginId(DEFAULT_USER); if (user == null) { user = new User(); user.setLoginId(DEFAULT_USER); appCtx.getConfigurationService().save(user); Group group = new Group(DEFAULT_USER); user.getGroups().add(group); appCtx.getConfigurationService().save(group); for (Privilege priv : Privilege.values()) { GroupPrivilege groupPriv = new GroupPrivilege(group.getId(), priv.name()); group.getGroupPrivileges().add(groupPriv); appCtx.getConfigurationService().save(groupPriv); } UserGroup userGroup = new UserGroup(user.getId(), group.getId()); appCtx.getConfigurationService().save(userGroup); } appCtx.setUser(user); login(user); } }