java.lang.Object
dk.cloudcreate.essentials.shared.Exceptions
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleandoesStackTraceContainExceptionOfType(Throwable exception, Class<?> exceptionType) Check if the stack trace (including causes) contains an exception of a specified type.static ThrowablegetRootCause(Throwable exception) Get the root cause (top most parent) of an Exception.static StringgetStackTrace(Throwable throwable) Get the stacktrace of thethrowableas a Stringstatic <T extends Throwable,R>
RAllows us to sneaky throw a checked exception without having to wrap it
Use with caution
-
Constructor Details
-
Exceptions
public Exceptions()
-
-
Method Details
-
sneakyThrow
Allows us to sneaky throw a checked exception without having to wrap it
Use with caution- Throws:
T extends Throwable
-
getStackTrace
Get the stacktrace of thethrowableas a String- Parameters:
throwable- the exception- Returns:
- the
throwable's full stacktrace
-
getRootCause
Get the root cause (top most parent) of an Exception.- Parameters:
exception- the exception we want the root cause of- Returns:
- the root cause of the exception - will never be null
-
doesStackTraceContainExceptionOfType
public static boolean doesStackTraceContainExceptionOfType(Throwable exception, Class<?> exceptionType) Check if the stack trace (including causes) contains an exception of a specified type.- Parameters:
exception- the root exceptionexceptionType- the type of exception to look for- Returns:
- true if the exception or one of its causes matches the specified type, false otherwise
-