-
- All Implemented Interfaces:
-
java.io.Serializable
public final class CompositeException extends RuntimeException
Represents an exception that is a composite of one or more other exceptions. A
{@code 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{@code 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 Summary
Constructors Constructor Description CompositeException(String messagePrefix, Collection<out Throwable> errors)
Constructs a CompositeException with the given prefix and error collection. CompositeException(Collection<out Throwable> errors)
Constructs a CompositeException instance with the Throwable elementsof the supplied Collection. CompositeException(Array<Throwable> errors)
Constructs a CompositeException instance with the supplied initial Throwables.
-
Method Summary
Modifier and Type Method Description List<Throwable>
getExceptions()
Retrieves the list of exceptions that make up the {@code CompositeException}
String
getMessage()
synchronized Throwable
getCause()
void
printStackTrace()
All of the following {@code printStackTrace}
functionality is derived from JDK Throwable{@code printStackTrace}
.void
printStackTrace(PrintStream s)
void
printStackTrace(PrintWriter s)
-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, setStackTrace, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
CompositeException
CompositeException(String messagePrefix, Collection<out Throwable> errors)
Constructs a CompositeException with the given prefix and error collection.- Parameters:
messagePrefix
- the prefix to use (actually unused)errors
- the collection of errors
-
CompositeException
CompositeException(Collection<out Throwable> errors)
Constructs a CompositeException instance with the Throwable elementsof the supplied Collection.- Parameters:
errors
- the collection of errors
-
-
Method Detail
-
getExceptions
List<Throwable> getExceptions()
Retrieves the list of exceptions that make up the
{@code CompositeException}
-
getMessage
String getMessage()
-
printStackTrace
void printStackTrace()
All of the following
{@code printStackTrace}
functionality is derived from JDK Throwable{@code printStackTrace}
. In particular, the{@code PrintStreamOrWriter}
abstraction is copied wholesale.Changes from the official JDK implementation:- no infinite loop detection
- smaller critical section holding PrintStream lock
- explicit knowledge about the exceptions List that this loops through
-
printStackTrace
void printStackTrace(PrintStream s)
-
printStackTrace
void printStackTrace(PrintWriter s)
-
-
-
-