Package org.apache.juneau.common.utils
Class ThrowableUtils
java.lang.Object
org.apache.juneau.common.utils.ThrowableUtils
Various utility methods for creating and working with throwables.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic interfaceInterface used withUtils.safeSupplier(SupplierWithThrowable).
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic RuntimeExceptionasRuntimeException(Throwable cause) Creates a newRuntimeException.static <T> TCasts or wraps the specified throwable to the specified type.static <T extends Throwable>
 TSame asThrowable.getCause()but searches the throwable chain for an exception of the specified type.static StringConvenience method for getting a stack trace as a string.static intCalculates a 16-bit hash for the specified throwable based on it's stack trace.
- 
Constructor Details- 
ThrowableUtilspublic ThrowableUtils()
 
- 
- 
Method Details- 
asRuntimeExceptionCreates a newRuntimeException.- Parameters:
- cause- The caused-by exception.
- Returns:
- A new RuntimeException, or the same exception if it's already of that type.
 
- 
castCasts or wraps the specified throwable to the specified type.- Type Parameters:
- T- The class to cast to.
- Parameters:
- type- The class to cast to.
- t- The throwable to cast.
- Returns:
- Either the same exception if it's already the specified type, or a wrapped exception.
 
- 
getCauseSame asThrowable.getCause()but searches the throwable chain for an exception of the specified type.- Type Parameters:
- T- The throwable type to search for.
- Parameters:
- c- The throwable type to search for.
- t- The throwable to search.
- Returns:
- The exception, or null if not found.
 
- 
getStackTraceConvenience method for getting a stack trace as a string.- Parameters:
- t- The throwable to get the stack trace from.
- Returns:
- The same content that would normally be rendered via t.printStackTrace() 
 
- 
hashCalculates a 16-bit hash for the specified throwable based on it's stack trace.- Parameters:
- t- The throwable to calculate the stack trace on.
- stopClass- Optional stop class on which to stop calculation of a stack trace beyond when found.
- Returns:
- A calculated hash.
 
 
-