public final class CompositeException extends 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(Collection<? extends Throwable> errors) |
CompositeException(String messagePrefix,
Collection<? extends Throwable> errors)
Deprecated.
please use
CompositeException(Collection) |
CompositeException(Throwable... errors)
Constructs a CompositeException instance with the supplied initial Throwables.
|
Modifier and Type | Method and Description |
---|---|
Throwable |
getCause() |
List<Throwable> |
getExceptions()
Retrieves the list of exceptions that make up the
CompositeException |
String |
getMessage() |
void |
printStackTrace()
|
void |
printStackTrace(PrintStream s) |
void |
printStackTrace(PrintWriter s) |
addSuppressed, fillInStackTrace, getLocalizedMessage, getStackTrace, getSuppressed, initCause, setStackTrace, toString
@Deprecated public CompositeException(String messagePrefix, Collection<? extends Throwable> errors)
CompositeException(Collection)
messagePrefix
- the prefix to use (actually unused)errors
- the collection of errorspublic CompositeException(Collection<? extends Throwable> errors)
@Experimental public CompositeException(Throwable... errors)
errors
- the array of Throwablespublic List<Throwable> getExceptions()
CompositeException
public String getMessage()
getMessage
in class 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 Throwable
public void printStackTrace(PrintStream s)
printStackTrace
in class Throwable
public void printStackTrace(PrintWriter s)
printStackTrace
in class Throwable
Copyright © 2024. All rights reserved.