Example usage for org.springframework.core NestedCheckedException contains

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

Introduction

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

Prototype

public boolean contains(@Nullable Class<?> exType) 

Source Link

Document

Check whether this exception contains an exception of the given type: either it is of the given class itself or it contains a nested cause of the given type.

Usage

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

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