public final class CompositeException
extends java.lang.RuntimeException
CompositeException
does not modify the structure of any exception it wraps, but at print-time it iterates through the list of
Throwables contained in the composite in order to print them all.
Its invariant is to contain an immutable, ordered (by insertion order), unique list of non-composite
exceptions. You can retrieve individual exceptions in this list with getExceptions()
.
The printStackTrace()
implementation handles the StackTrace in a customized way instead of using
getCause()
so that it can avoid circular references.
If you invoke getCause()
, it will lazily create the causal chain but will stop if it finds any
Throwable in the chain that it has already seen.Constructor and Description |
---|
CompositeException(java.lang.Iterable<? extends java.lang.Throwable> errors)
Constructs a CompositeException with the given array of Throwables as the
list of suppressed exceptions.
|
CompositeException(java.lang.Throwable... exceptions)
Constructs a CompositeException with the given array of Throwables as the
list of suppressed exceptions.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Throwable |
getCause() |
java.util.List<java.lang.Throwable> |
getExceptions()
Retrieves the list of exceptions that make up the
CompositeException . |
java.lang.String |
getMessage() |
void |
printStackTrace()
All of the following
printStackTrace functionality is derived from JDK Throwable
printStackTrace . |
void |
printStackTrace(java.io.PrintStream s) |
void |
printStackTrace(java.io.PrintWriter s) |
int |
size()
Returns the number of suppressed exceptions.
|
public CompositeException(java.lang.Throwable... exceptions)
exceptions
- the Throwables to have as initially suppressed exceptionsjava.lang.IllegalArgumentException
- if exceptions
is empty.public CompositeException(java.lang.Iterable<? extends java.lang.Throwable> errors)
errors
- the Throwables to have as initially suppressed exceptionsjava.lang.IllegalArgumentException
- if errors
is empty.public java.util.List<java.lang.Throwable> getExceptions()
CompositeException
.CompositeException
, as a List
of Throwable
spublic java.lang.String getMessage()
getMessage
in class java.lang.Throwable
public java.lang.Throwable getCause()
getCause
in class java.lang.Throwable
public void printStackTrace()
printStackTrace
functionality is derived from JDK Throwable
printStackTrace
. In particular, the PrintStreamOrWriter
abstraction is copied wholesale.
Changes from the official JDK implementation:PrintStream
lockList
that this loops throughprintStackTrace
in class java.lang.Throwable
public void printStackTrace(java.io.PrintStream s)
printStackTrace
in class java.lang.Throwable
public void printStackTrace(java.io.PrintWriter s)
printStackTrace
in class java.lang.Throwable
public int size()