-
- All Implemented Interfaces:
-
java.io.Serializable
public final class ExtCompositeException extends RuntimeException
Represents an exception that is a composite of one or more other exceptions. A
{@code ExtCompositeException}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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description abstract classPrintStreamOrWriterfinal classWrappedPrintStreamSame abstraction and implementation as in JDK to allow PrintStream and PrintWriter to share implementation.
final classWrappedPrintWriterfinal classCompositeExceptionCausalChain
-
Constructor Summary
Constructors Constructor Description ExtCompositeException(Array<Throwable> exceptions)Constructs a ExtCompositeException with the given array of Throwables as the list of suppressed exceptions. ExtCompositeException(Iterable<Out Throwable> errors)Constructs a ExtCompositeException with the given array of Throwables as the list of suppressed exceptions.
-
Method Summary
Modifier and Type Method Description voidprintStackTrace()All of the following {@code printStackTrace}functionality is derived from JDK Throwable{@code printStackTrace}.voidprintStackTrace(PrintStream s)voidprintStackTrace(PrintWriter s)intsize()Returns the number of suppressed exceptions. ThrowablegetRootCause(Throwable e)Returns the root cause of {@code e}.List<Throwable>getExceptions()Retrieves the list of exceptions that make up the {@code ExtCompositeException}.StringgetMessage()synchronized ThrowablegetCause()-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getOurStackTrace, getStackTrace, getStackTraceDepth, getStackTraceElement, getSuppressed, initCause, printEnclosedStackTrace, printStackTrace, readObject, setStackTrace, toString, validateSuppressedExceptionsList, writeObject -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
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)
-
size
int size()
Returns the number of suppressed exceptions.
-
getRootCause
Throwable getRootCause(Throwable e)
Returns the root cause of
{@code e}. If{@code e.getCause()}returns{@code null}or{@code e}, just return{@code e}itself.- Parameters:
e- the Throwable{@code e}.
-
getExceptions
@NonNull() List<Throwable> getExceptions()
Retrieves the list of exceptions that make up the
{@code ExtCompositeException}.
-
getMessage
@NonNull() String getMessage()
-
-
-
-