Example usage for org.springframework.core NestedCheckedException getMostSpecificCause

List of usage examples for org.springframework.core NestedCheckedException getMostSpecificCause

Introduction

In this page you can find the example usage for org.springframework.core NestedCheckedException getMostSpecificCause.

Prototype

public Throwable getMostSpecificCause() 

Source Link

Document

Retrieve the most specific cause of this exception, that is, either the innermost cause (root cause) or this exception itself.

Usage

From source file:org.springframework.web.server.handler.ExceptionHandlingWebHandler.java

private void logException(Throwable ex) {
    @SuppressWarnings("serial")
    NestedCheckedException nestedException = new NestedCheckedException("", ex) {
    };/*from  w w w .j a va  2s  .  c  o m*/

    if ("Broken pipe".equalsIgnoreCase(nestedException.getMostSpecificCause().getMessage())
            || DISCONNECTED_CLIENT_EXCEPTIONS.contains(ex.getClass().getSimpleName())) {

        if (disconnectedClientLogger.isTraceEnabled()) {
            disconnectedClientLogger.trace("Looks like the client has gone away", ex);
        } else if (disconnectedClientLogger.isDebugEnabled()) {
            disconnectedClientLogger.debug("Looks like the client has gone away: "
                    + nestedException.getMessage() + " (For full stack trace, set the '"
                    + DISCONNECTED_CLIENT_LOG_CATEGORY + "' log category to TRACE level)");
        }
    } else {
        logger.error("Could not complete request", ex);
    }
}