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.util.Collection<? extends java.lang.Throwable> errors)
Constructs a CompositeException instance with the Throwable elements
of the supplied Collection.
|
CompositeException(java.lang.String messagePrefix,
java.util.Collection<? extends java.lang.Throwable> errors)
Deprecated.
please use
CompositeException(Collection) |
CompositeException(java.lang.Throwable... errors)
Constructs a CompositeException instance with the supplied initial Throwables.
|
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) |
@Deprecated public CompositeException(java.lang.String messagePrefix, java.util.Collection<? extends java.lang.Throwable> errors)
CompositeException(Collection)
messagePrefix
- the prefix to use (actually unused)errors
- the collection of errorspublic CompositeException(java.util.Collection<? extends java.lang.Throwable> errors)
Null values are replaced by NullPointerException
.
errors
- the collection of errorspublic CompositeException(java.lang.Throwable... errors)
errors
- the array of Throwablespublic 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