Package rx.exceptions
Class CompositeException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
rx.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 class
(package private) static class
(package private) static final class
Same abstraction and implementation as in JDK to allow PrintStream and PrintWriter to share implementation(package private) static final class
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCompositeException
(String messagePrefix, Collection<? extends Throwable> errors) Deprecated.CompositeException
(Throwable... errors) Constructs a CompositeException instance with the supplied initial Throwables.CompositeException
(Collection<? extends Throwable> errors) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
appendStackTrace
(StringBuilder bldr, Throwable ex, String prefix) getCause()
Retrieves the list of exceptions that make up theCompositeException
private Throwable
Returns the root cause ofe
.void
void
void
private void
Special handling for printing out aCompositeException
.Methods inherited from class java.lang.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
Deprecated.please useCompositeException(Collection)
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
Constructs a CompositeException instance with the supplied initial Throwables.- Parameters:
errors
- the array of Throwables
-
-
Method Details
-
getExceptions
Retrieves the list of exceptions that make up theCompositeException
-
getMessage
- Overrides:
getMessage
in classThrowable
-
getCause
-
printStackTrace
public void printStackTrace()All of the followingprintStackTrace
functionality is derived from JDKThrowable
printStackTrace
. In particular, thePrintStreamOrWriter
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
- Overrides:
printStackTrace
in classThrowable
-
printStackTrace
- Overrides:
printStackTrace
in classThrowable
-
printStackTrace
- Overrides:
printStackTrace
in classThrowable
-
printStackTrace
Special handling for printing out aCompositeException
. Loops through all inner exceptions and prints them out.- Parameters:
s
- stream to print to
-
appendStackTrace
-
getListOfCauses
-
getRootCause
Returns the root cause ofe
. Ife.getCause()
returns ore
, just returne
itself.- Parameters:
e
- theThrowable
e
.- Returns:
- The root cause of
e
. Ife.getCause()
returns ore
, just returne
itself.
-
CompositeException(Collection)