List of usage examples for org.apache.commons.lang3.exception ExceptionUtils getThrowableCount
public static int getThrowableCount(final Throwable throwable)
Counts the number of Throwable
objects in the exception chain.
A throwable without cause will return 1
.
From source file:com.thinkbiganalytics.nifi.rest.client.NifiRestClientExceptionTranslator.java
public static Throwable translateException(Throwable e) { //Return if its already translated to a NifiClientRuntimeException if (e instanceof NifiClientRuntimeException) { return e; }//from www .ja v a 2 s. c o m if (e instanceof NotFoundException) { return new NifiComponentNotFoundException(e.getMessage()); } else if (e instanceof NullPointerException) { return new NifiConnectionException("Verify NiFi is running and try again", e); } else if (e instanceof ProcessingException) { int throwables = ExceptionUtils.getThrowableCount(e); if (throwables > 1) { Throwable rootCause = ExceptionUtils.getRootCause(e); if (rootCause instanceof NoHttpResponseException || rootCause instanceof HttpHostConnectException || rootCause instanceof ConnectException) { //connection error return new NifiConnectionException(e.getMessage(), e); } } } return new NifiClientRuntimeException(e); }