Package io.microsphere.util
Class ThrowableUtils
- java.lang.Object
-
- io.microsphere.util.ThrowableUtils
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.ThrowablegetRootCause(java.lang.Throwable throwable)Retrieves the root cause of the givenThrowableby traversing the cause chain until a throwable with no cause is found.
-
-
-
Method Detail
-
getRootCause
public static java.lang.Throwable getRootCause(java.lang.Throwable throwable)
Retrieves the root cause of the givenThrowableby traversing the cause chain until a throwable with no cause is found.Example Usage
Exception root = new IllegalArgumentException("root"); Exception wrapped = new RuntimeException("wrapped", root); Throwable result = ThrowableUtils.getRootCause(wrapped); System.out.println(result.getMessage()); // "root"- Parameters:
throwable- the throwable whose root cause is to be determined; must not benull- Returns:
- the root cause of the throwable chain
- Since:
- 1.0.0
-
-