Example usage for com.vaadin.server ErrorMessage getFormattedHtmlMessage

List of usage examples for com.vaadin.server ErrorMessage getFormattedHtmlMessage

Introduction

In this page you can find the example usage for com.vaadin.server ErrorMessage getFormattedHtmlMessage.

Prototype

public String getFormattedHtmlMessage();

Source Link

Document

Returns the HTML formatted message to show in as the error message on the client.

Usage

From source file:de.metas.procurement.webui.server.NotificationErrorHandler.java

License:Open Source License

@Override
protected void displayError(final ErrorMessage errorMessage, final ErrorEvent event) {
    final Notification notification = new Notification("", errorMessage.getFormattedHtmlMessage(), defaultType,
            true);//from  w ww . j a v a 2  s.  c  o m
    notification.show(Page.getCurrent());
}

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(/*from ww  w . j av a  2  s.com*/
                "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);
        }
    }
}