Delegate getRootCause through to Guava's implementation to avoid re-implementing the wheel (keep our wrapper method to preserve null safe handling). (#692)

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Adrian Sutton 6 years ago committed by GitHub
parent b4638ea1d1
commit b28258b8c4
  1. 14
      util/src/main/java/tech/pegasys/pantheon/util/ExceptionUtils.java

@ -12,6 +12,8 @@
*/
package tech.pegasys.pantheon.util;
import com.google.common.base.Throwables;
public class ExceptionUtils {
private ExceptionUtils() {}
@ -23,16 +25,6 @@ public class ExceptionUtils {
* @return The root cause
*/
public static Throwable rootCause(final Throwable throwable) {
Throwable cause = throwable;
while (cause != null) {
if (cause.getCause() == null) {
break;
}
cause = cause.getCause();
}
return cause;
return throwable != null ? Throwables.getRootCause(throwable) : null;
}
}

Loading…
Cancel
Save