Class CompositeException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
io.reactivex.rxjava3.exceptions.CompositeException
- All Implemented Interfaces:
Serializable
Represents an exception that is a composite of one or more other exceptions. A
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.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classContains a formatted message with a simplified representation of the exception graph contained within the CompositeException.(package private) static class(package private) static final classSame abstraction and implementation as in JDK to allow PrintStream and PrintWriter to share implementation.(package private) static final classSame abstraction and implementation as in JDK to allow PrintStream and PrintWriter to share implementation. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCompositeException(@NonNull Iterable<? extends Throwable> errors) Constructs a CompositeException with the given array of Throwables as the list of suppressed exceptions.CompositeException(@NonNull Throwable... exceptions) Constructs a CompositeException with the given array of Throwables as the list of suppressed exceptions. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidappendStackTrace(CompositeException.PrintStreamOrWriter output, Throwable ex, String prefix) getCause()Retrieves the list of exceptions that make up theCompositeException.voidprivate voidSpecial handling for printing out aCompositeException.voidvoidintsize()Returns the number of suppressed exceptions.Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getLocalizedMessage, getStackTrace, getSuppressed, initCause, setStackTrace, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
exceptions
-
message
-
cause
-
-
Constructor Details
-
CompositeException
Constructs a CompositeException with the given array of Throwables as the list of suppressed exceptions.- Parameters:
exceptions- the Throwables to have as initially suppressed exceptions- Throws:
IllegalArgumentException- ifexceptionsis empty.
-
CompositeException
Constructs a CompositeException with the given array of Throwables as the list of suppressed exceptions.- Parameters:
errors- the Throwables to have as initially suppressed exceptions- Throws:
IllegalArgumentException- iferrorsis empty.
-
-
Method Details
-
getExceptions
-
getMessage
- Overrides:
getMessagein classThrowable
-
getCause
-
printStackTrace
public void printStackTrace()All of the followingprintStackTracefunctionality is derived from JDKThrowableprintStackTrace. In particular, thePrintStreamOrWriterabstraction is copied wholesale. Changes from the official JDK implementation:- no infinite loop detection
- smaller critical section holding
PrintStreamlock - explicit knowledge about the exceptions
Listthat this loops through
- Overrides:
printStackTracein classThrowable
-
printStackTrace
- Overrides:
printStackTracein classThrowable
-
printStackTrace
- Overrides:
printStackTracein classThrowable
-
printStackTrace
Special handling for printing out aCompositeException. Loops through all inner exceptions and prints them out.- Parameters:
output- stream to print to
-
appendStackTrace
private void appendStackTrace(CompositeException.PrintStreamOrWriter output, Throwable ex, String prefix) -
size
public int size()Returns the number of suppressed exceptions.- Returns:
- the number of suppressed exceptions
-