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 composit 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) |
CompositeException(java.lang.String messagePrefix,
java.util.Collection<? extends java.lang.Throwable> errors) |
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) |
public CompositeException(java.lang.String messagePrefix, java.util.Collection<? extends java.lang.Throwable> errors)
public CompositeException(java.util.Collection<? extends java.lang.Throwable> errors)
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