public class ExceptionUtils
extends java.lang.Object
Created: 2017. 10. 7.
| Constructor | Description |
|---|---|
ExceptionUtils() |
| Modifier and Type | Method | Description |
|---|---|---|
static java.lang.Throwable |
getRootCause(java.lang.Throwable t) |
Method that can be used to find the "root cause", innermost
of chained (wrapped) exceptions.
|
static void |
throwAsIAE(java.lang.Throwable t) |
Method that will wrap 't' as an
IllegalArgumentException if it
is a checked exception; otherwise (runtime exception or error) throw as is. |
static void |
throwAsIAE(java.lang.Throwable t,
java.lang.String msg) |
Method that will wrap 't' as an
IllegalArgumentException (and with
specified message) if it is a checked exception; otherwise (runtime exception or error)
throw as is. |
static java.lang.Throwable |
throwIfError(java.lang.Throwable t) |
Helper method that will check if argument is an
Error,
and if so, (re)throw it; otherwise just return. |
static java.lang.Throwable |
throwIfIOE(java.lang.Throwable t) |
Helper method that will check if argument is an
IOException,
and if so, (re)throw it; otherwise just return. |
static java.lang.Throwable |
throwIfRTE(java.lang.Throwable t) |
Helper method that will check if argument is an
RuntimeException,
and if so, (re)throw it; otherwise just return. |
static java.lang.Throwable |
throwRootCauseIfIOE(java.lang.Throwable t) |
Method that works like by calling
getRootCause(java.lang.Throwable) and then
either throwing it (if instanceof IOException), or
return. |
static void |
unwrapAndThrowAsIAE(java.lang.Throwable t) |
Method that will locate the innermost exception for given Throwable;
and then wrap it as an
IllegalArgumentException if it
is a checked exception; otherwise (runtime exception or error) throw as is |
static void |
unwrapAndThrowAsIAE(java.lang.Throwable t,
java.lang.String msg) |
Method that will locate the innermost exception for given Throwable;
and then wrap it as an
IllegalArgumentException if it
is a checked exception; otherwise (runtime exception or error) throw as is |
public static java.lang.Throwable getRootCause(java.lang.Throwable t)
t - the Throwable to possibly propagatepublic static java.lang.Throwable throwIfError(java.lang.Throwable t)
Error,
and if so, (re)throw it; otherwise just return.t - the Throwable to possibly propagatepublic static java.lang.Throwable throwIfRTE(java.lang.Throwable t)
RuntimeException,
and if so, (re)throw it; otherwise just return.t - the Throwable to possibly propagatepublic static java.lang.Throwable throwIfIOE(java.lang.Throwable t)
throws java.io.IOException
IOException,
and if so, (re)throw it; otherwise just return.t - the Throwable to possibly propagatejava.io.IOException - rethrow the IOExceptionpublic static java.lang.Throwable throwRootCauseIfIOE(java.lang.Throwable t)
throws java.io.IOException
getRootCause(java.lang.Throwable) and then
either throwing it (if instanceof IOException), or
return.t - the Throwable to possibly propagatejava.io.IOException - rethrow the IOExceptionpublic static void throwAsIAE(java.lang.Throwable t)
IllegalArgumentException if it
is a checked exception; otherwise (runtime exception or error) throw as is.t - the Throwable to possibly propagatepublic static void throwAsIAE(java.lang.Throwable t,
java.lang.String msg)
IllegalArgumentException (and with
specified message) if it is a checked exception; otherwise (runtime exception or error)
throw as is.t - the Throwable to possibly propagatemsg - the detail messagepublic static void unwrapAndThrowAsIAE(java.lang.Throwable t)
IllegalArgumentException if it
is a checked exception; otherwise (runtime exception or error) throw as ist - the Throwable to possibly propagatepublic static void unwrapAndThrowAsIAE(java.lang.Throwable t,
java.lang.String msg)
IllegalArgumentException if it
is a checked exception; otherwise (runtime exception or error) throw as ist - the Throwable to possibly propagatemsg - the detail msgCopyright © 2008–2017 The Aspectran Project. All rights reserved.