use of com.vaadin.server.SystemError in project SORMAS-Project by hzi-braunschweig.
the class SormasErrorHandler method handleError.
public static void handleError(ErrorEvent event) {
Logger logger = LoggerFactory.getLogger(SormasErrorHandler.class);
final 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;
}
ErrorMessage errorMessage = getErrorMessageForException(t);
if (t != null) {
// log the error or warning
if (errorMessage instanceof SystemError) {
logger.error(getMessage(t), 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);
}
}
}
Aggregations