Example usage for org.springframework.core NestedCheckedException NestedCheckedException

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

Introduction

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

Prototype

public NestedCheckedException(@Nullable String msg, @Nullable Throwable cause) 

Source Link

Document

Construct a NestedCheckedException with the specified detail message and nested exception.

Usage

From source file:sample.data.elasticsearch.SampleElasticsearchApplicationTests.java

private boolean serverNotRunning(IllegalStateException ex) {
    @SuppressWarnings("serial")
    NestedCheckedException nested = new NestedCheckedException("failed", ex) {
    };/*from   ww w.  j a  v a2  s .c  o m*/
    if (nested.contains(ConnectException.class)) {
        Throwable root = nested.getRootCause();
        if (root.getMessage().contains("Connection refused")) {
            return true;
        }
    }
    return false;
}

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

private void logException(Throwable ex) {
    @SuppressWarnings("serial")
    NestedCheckedException nestedException = new NestedCheckedException("", ex) {
    };//from  ww w  .j a  v a  2  s.co  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);
    }
}