Search in sources :

Example 1 with SilentException

use of com.haulmont.cuba.core.global.SilentException in project cuba by cuba-platform.

the class AppLog method log.

@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
public void log(ErrorEvent event) {
    Throwable t = event.getThrowable();
    if (t instanceof SilentException)
        return;
    if (t instanceof Validator.InvalidValueException)
        return;
    if (t instanceof SocketException || ExceptionUtils.getRootCause(t) instanceof SocketException) {
        // Most likely client browser closed socket
        LogItem item = new LogItem(LogLevel.WARNING, "SocketException in CommunicationManager. Most likely client (browser) closed socket.", null);
        log(item);
        return;
    }
    // Support Tomcat 8 ClientAbortException
    if (StringUtils.contains(ExceptionUtils.getMessage(t), "ClientAbortException")) {
        // Most likely client browser closed socket
        LogItem item = new LogItem(LogLevel.WARNING, "ClientAbortException on write response to client. Most likely client (browser) closed socket.", null);
        log(item);
        return;
    }
    Throwable rootCause = ExceptionUtils.getRootCause(t);
    if (rootCause == null)
        rootCause = t;
    Logging annotation = rootCause.getClass().getAnnotation(Logging.class);
    Logging.Type loggingType = annotation == null ? Logging.Type.FULL : annotation.value();
    if (loggingType == Logging.Type.NONE)
        return;
    // Finds the original source of the error/exception
    AbstractComponent component = DefaultErrorHandler.findAbstractComponent(event);
    StringBuilder msg = new StringBuilder();
    msg.append("Exception");
    if (component != null)
        msg.append(" in ").append(component.getClass().getName());
    msg.append(": ");
    if (loggingType == Logging.Type.BRIEF) {
        error(msg + rootCause.toString());
    } else {
        LogItem item = new LogItem(LogLevel.ERROR, msg.toString(), t);
        log(item);
    }
}
Also used : Logging(com.haulmont.cuba.core.global.Logging) SocketException(java.net.SocketException) AbstractComponent(com.vaadin.ui.AbstractComponent) SilentException(com.haulmont.cuba.core.global.SilentException)

Aggregations

Logging (com.haulmont.cuba.core.global.Logging)1 SilentException (com.haulmont.cuba.core.global.SilentException)1 AbstractComponent (com.vaadin.ui.AbstractComponent)1 SocketException (java.net.SocketException)1