微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

com.vaadin.server.ErrorEvent的实例源码

项目:Metasfresh-procurement-webui    文件AbstractErrorHandler.java   
@Override
public final void error(final ErrorEvent event)
{
    //
    // Extract the relevant exception
    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;
    }
    t = DefaultErrorHandler.findRelevantThrowable(t);

    //
    // Create error message
    final ErrorMessage errorMessage = createErrorMessage(t);

    //
    // display it
    displayError(errorMessage,event);

    // also print the error on console
    logger.error("",t);
}
项目:cuba    文件InvalidValueExceptionHandler.java   
@Override
public boolean handle(ErrorEvent event,App app) {
    boolean handled = super.handle(event,app);

    //noinspection ThrowableResultOfMethodCallIgnored
    if (handled && event.getThrowable() != null) {
        // Finds the original source of the error/exception
        AbstractComponent component = DefaultErrorHandler.findAbstractComponent(event);
        if (component != null) {
            component.markAsDirty();
        }

        if (component instanceof Component.Focusable) {
            ((Component.Focusable) component).focus();
        }

        //noinspection ThrowableResultOfMethodCallIgnored
        if (event.getThrowable() instanceof Validator.InvalidValueException) {
            app.getAppUI().discardAccumulatedEvents();
        }
    }
    return handled;
}
项目:cuba    文件AbstractExceptionHandler.java   
@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);
            return true;
        }
        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.getThrowable());
                    return true;
                }
            }
        }
    }
    return false;
}
项目:hawkbit    文件HawkbitUIErrorHandler.java   
@Override
public void error(final ErrorEvent event) {

    final HawkbitErrorNotificationMessage message = buildNotification(getRootExceptionFrom(event));
    if (event instanceof ConnectorErrorEvent) {
        final Connector connector = ((ConnectorErrorEvent) event).getConnector();
        if (connector instanceof UI) {
            final UI uiInstance = (UI) connector;
            uiInstance.access(() -> message.show(uiInstance.getPage()));
            return;
        }
    }

    final Optional<Page> originError = getPageOriginError(event);
    if (originError.isPresent()) {
        message.show(originError.get());
        return;
    }

    HawkbitErrorNotificationMessage.show(message.getCaption(),message.getDescription(),Type.HUMANIZED_MESSAGE);
}
项目:enterprise-app    文件EnterpriseApplication.java   
/**
 * Adds a default transaction listener.
 */
@Override
public void init() {
    final LegacyApplication app = this;

    VaadinSession.getCurrent().setErrorHandler(new ErrorHandler() {
        private static final long serialVersionUID = 1L;

        @Override
        public void error(ErrorEvent event) {
            Utils.terminalError(event,app);
        }
    });

    if(!Db.isInitialized()) {
        logger.warn("No TransactionListener added: Database is not initialized. You can initialize a database configuring a new 'DefaultTransactionListener' in your web.xml and adding a 'configuration.properties' file to your classpath.");
    }

    VaadinSession.getCurrent().setAttribute("application",this);
}
项目:vaadin-vertx-samples    文件VertxPushHandler.java   
/**
 * Call the session's {@link ErrorHandler},if it has one,with the given
 * exception wrapped in an {@link ErrorEvent}.
 */
private void callErrorHandler(VaadinSession session,Exception e) {
    try {
        ErrorHandler errorHandler = ErrorEvent.findErrorHandler(session);
        if (errorHandler != null) {
            errorHandler.error(new ErrorEvent(e));
        }
    } catch (Exception ex) {
        // Let's not allow error handling to cause trouble; log fails
        getLogger().log(Level.WARNING,"ErrorHandler call Failed",ex);
    }
}
项目:Metasfresh-procurement-webui    文件ForwardingErrorHandler.java   
@Override
protected void displayError(final ErrorMessage errorMessage,final ErrorEvent event)
{
    if (component != null)
    {
        component.setComponentError(errorMessage);
    }
}
项目:cuba    文件DefaultExceptionHandler.java   
@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;
    }

    // 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;
}
项目:Vaadin4Spring-MVP-Sample-SpringSecurity    文件SpringSecurityErrorHandler.java   
public static void doDefault(ErrorEvent event) {
    Throwable t = event.getThrowable();
    if (t instanceof SocketException) {
        // Most likely client browser closed socket
        getLogger().info(
                "SocketException in CommunicationManager."
                        + " Most likely client (browser) closed socket.");
        return;
    }

    t = findRelevantThrowable(t);

    /*
     * Handle SpringSecurity 
     */
    if (t instanceof AccessDeniedException) {

        EventBus eventBus = SpringApplicationContext.getEventBus();
        eventBus.publish(EventScope.UI,eventBus,new AccessDeniedEvent(t));

        getLogger().log(Level.FINE,"Access is denied",t);
        return;
    }

    // Finds the original source of the error/exception
    AbstractComponent component = findAbstractComponent(event);
    if (component != null) {
        // Shows the error in AbstractComponent
        ErrorMessage errorMessage = AbstractErrorMessage
                .getErrorMessageForException(t);
        component.setComponentError(errorMessage);
    }

    // also print the error on console
    getLogger().log(Level.SEVERE,"",t);
}
项目:Vaadin4Spring-MVP-Sample-SpringSecurity    文件SpringSecurityErrorHandler.java   
/**
 * Returns the AbstractComponent associated with the given error if such can
 * be found
 * 
 * @param event
 *            The error to investigate
 * @return The {@link AbstractComponent} to error relates to or null if
 *         Could not be determined or if the error does not relate to any
 *         AbstractComponent.
 */
public static AbstractComponent findAbstractComponent(
        com.vaadin.server.ErrorEvent event) {
    if (event instanceof ConnectorErrorEvent) {
        Component c = findComponent(((ConnectorErrorEvent) event)
                .getConnector());
        if (c instanceof AbstractComponent) {
            return (AbstractComponent) c;
        }
    }

    return null;
}
项目:enterprise-app    文件Utils.java   
/**
 * Shows a terminal error.
 * @param event
 * @param application
 */
public static void terminalError(ErrorEvent event,LegacyApplication application) {
    String errorTime = Utils.getCurrentTimeAndDate();
    logger.error("DefaultApplication Terminal Error (" + errorTime + "):",event.getThrowable());
    String errorMessage = Constants.uiTerminalErrorMessage + "<br/><i>" + Constants.uiErrorTime + ": " + errorTime + "</i>";

    if(application.getMainWindow() != null) {
        application.getMainWindow().showNotification(Constants.uiError,errorMessage,Notification.TYPE_ERROR_MESSAGE);
    }
}
项目:jdal    文件SecurityErrorHandler.java   
@Override
public void error(ErrorEvent event) {
    Throwable t = findRelevantThrowable(event.getThrowable());
    if (isSecurityException(t)) {
        handleSecurityException(t);

        return;
    }

    super.error(event);
}
项目:Metasfresh-procurement-webui    文件NotificationErrorHandler.java   
@Override
protected void displayError(final ErrorMessage errorMessage,final ErrorEvent event)
{
    final Notification notification = new Notification("",errorMessage.getFormattedHtmlMessage(),defaultType,true);
    notification.show(Page.getCurrent());
}
项目:hawkbit    文件HawkbitUIErrorHandler.java   
private static Throwable getRootExceptionFrom(final ErrorEvent event) {
    return getRootCauSEOf(event.getThrowable());
}
项目:Vaadin4Spring-MVP-Sample-SpringSecurity    文件SpringSecurityErrorHandler.java   
@Override
public void error(ErrorEvent event) {
    doDefault(event);
}
项目:enterprise-app    文件EnterpriseApplication.java   
/**
 * @deprecated see EnterpriseApplication.init
 */
@Deprecated
public void terminalError(ErrorEvent event) {
    Utils.terminalError(event,this);
}
项目:hawkbit    文件HawkbitUIErrorHandler.java   
private static Optional<Page> getPageOriginError(final ErrorEvent event) {

        final Component errorOrigin = findAbstractComponent(event);

        if (errorOrigin != null && errorOrigin.getUI() != null) {
            return Optional.fromNullable(errorOrigin.getUI().getPage());
        }

        return Optional.absent();
    }
项目:Metasfresh-procurement-webui    文件AbstractErrorHandler.java   
/**
 * displays the given error message.
 * 
 * @param errorMessage error message to be displayed
 * @param event original error event
 */
protected abstract void displayError(final ErrorMessage errorMessage,final ErrorEvent event);
项目:cuba    文件ExceptionHandler.java   
/**
 * Handle an exception. Implementation class should either handle the exception and return true,or return false
 * to delegate execution to the next handler in the chain of responsibility.
 * @param event error event containing the exception,generated by Vaadin
 * @param app   current {@link App} instance
 * @return      true if the exception has been successfully handled,false if not
 */
boolean handle(ErrorEvent event,App app);

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。