public abstract class ExceptionUtils extends Object
Constructor and Description |
---|
ExceptionUtils() |
Modifier and Type | Method and Description |
---|---|
static Exception |
toException(Throwable throwable)
Converts the given throwable to an
Exception if necessary. |
static RuntimeException |
uncheck(Throwable throwable)
Converts the given throwable to a
RuntimeException if necessary. |
public static RuntimeException uncheck(Throwable throwable)
RuntimeException
if necessary.
If throwable
is an Error
, it will be thrown.
If throwable
is a RuntimeException
, it will be returned unchanged.
If throwable
is not a RuntimeException
, a newly created RuntimeException
will be returned with the original throwable as the cause and with no message.
throwable
- the throwable to ensure is a runtime exceptionpublic static Exception toException(Throwable throwable)
Exception
if necessary.
If throwable
is an Error
, it will be thrown.
If throwable
is an Exception
, it will be returned unchanged.
If throwable
is not an Exception
, a newly created Exception
will be returned with the original throwable as the cause and with no message.
throwable
- the throwable to ensure is an exception