Package com.illumon.util
Class MultiException
java.lang.Object
java.lang.Throwable
java.lang.Exception
com.illumon.util.MultiException
- All Implemented Interfaces:
Serializable
public class MultiException extends Exception
An exception to use when a series of operations must all be executed, but may all throw exceptions themselves.
This allows for retention of all exception data.
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static Throwable[]
ZERO_LENGTH_THROWABLE_ARRAY
-
Constructor Summary
Constructors Constructor Description MultiException(String description, Throwable... causes)
Create a MultiException from an array of Throwable causes. -
Method Summary
Modifier and Type Method Description Throwable[]
getCauses()
String
getMessage()
static Exception
maybeWrapInMultiException(String description, Exception... causes)
If there is a single exception, return that exception; otherwise wrap the causes into a MultiException.static Throwable
maybeWrapInMultiException(String description, Throwable... causes)
If there is a single exception, return that exception; otherwise wrap the causes into a MultiException.static Throwable
maybeWrapInMultiException(String description, List<? extends Throwable> causes)
If there is a single exception, return that exception; otherwise wrap the causes into a MultiException.void
printStackTrace(PrintStream s)
void
printStackTrace(PrintWriter s)
String
toString()
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, setStackTrace
-
Field Details
-
Constructor Details
-
MultiException
Create a MultiException from an array of Throwable causes.- Parameters:
description
- the message to usecauses
- a list of causes
-
-
Method Details
-
maybeWrapInMultiException
If there is a single exception, return that exception; otherwise wrap the causes into a MultiException.- Parameters:
description
- the description for the MultiExceptioncauses
- the array of causes- Returns:
- a MultiException or the single Throwable
-
maybeWrapInMultiException
public static Throwable maybeWrapInMultiException(String description, List<? extends Throwable> causes)If there is a single exception, return that exception; otherwise wrap the causes into a MultiException.- Parameters:
description
- the description for the MultiExceptioncauses
- the list of causes- Returns:
- a MultiException or the single Throwable
-
maybeWrapInMultiException
If there is a single exception, return that exception; otherwise wrap the causes into a MultiException.- Parameters:
description
- the description for the MultiExceptioncauses
- the array of causes- Returns:
- a MultiException or the single Exception
-
getCauses
- Returns:
- all of the exceptions that resulted in this one.
-
printStackTrace
- Overrides:
printStackTrace
in classThrowable
-
printStackTrace
- Overrides:
printStackTrace
in classThrowable
-
getMessage
- Overrides:
getMessage
in classThrowable
-
toString
-