Example usage for org.springframework.core NestedCheckedException getRootCause

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

Introduction

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

Prototype

@Nullable
public Throwable getRootCause() 

Source Link

Document

Retrieve the innermost cause of this exception, if any.

Usage

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

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