Top Description Inners Fields Constructors Methods
io.reactivex.exceptions

public final Class CompositeException

extends RuntimeException
Class Inheritance
Imports
java.io.*, java.util.*, io.reactivex.annotations.NonNull

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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv abstract static class
pack-priv static class
CompositeException.WrappedPrintStream

Same abstraction and implementation as in JDK to allow PrintStream and PrintWriter to share implementation.

pack-priv static class

Field Summary

Modifier and TypeField and Description
private Throwable
private final List<Throwable>
private final String
private static final long

Constructor Summary

AccessConstructor and Description
public
CompositeException(Throwable...
the Throwables to have as initially suppressed exceptions
exceptions
)

Constructs a CompositeException with the given array of Throwables as the list of suppressed exceptions.

public
CompositeException(Iterable<? extends Throwable>
the Throwables to have as initially suppressed exceptions
errors
)

Constructs a CompositeException with the given array of Throwables as the list of suppressed exceptions.

Method Summary

Modifier and TypeMethod and Description
private void
public synchronized Throwable
getCause()

Overrides java.lang.Throwable.getCause.

Returns the cause of this throwable or null if the cause is nonexistent or unknown.
public List<Throwable>

Returns:

the exceptions that make up the CompositeException, as a List of Throwables
getExceptions
()

Retrieves the list of exceptions that make up the CompositeException.

private List<Throwable>
public String
getMessage()

Overrides java.lang.Throwable.getMessage.

Returns the detail message string of this throwable.
pack-priv Throwable

Returns:

The root cause of e. If e.getCause() returns null or e, just return e itself.
getRootCause
(Throwable
the Throwable e.
e
)

Returns the root cause of e.

public void
printStackTrace()

Overrides java.lang.Throwable.printStackTrace.

All of the following printStackTrace functionality is derived from JDK Throwable printStackTrace.
public void
printStackTrace(PrintStream
PrintStream to use for output
s
)

Overrides java.lang.Throwable.printStackTrace.

Prints this throwable and its backtrace to the specified print stream.
public void
printStackTrace(PrintWriter
PrintWriter to use for output
s
)

Overrides java.lang.Throwable.printStackTrace.

Prints this throwable and its backtrace to the specified print writer.
private void
printStackTrace(CompositeException.PrintStreamOrWriter
stream to print to
s
)

Special handling for printing out a CompositeException.

public int

Returns:

the number of suppressed exceptions
size
()

Returns the number of suppressed exceptions.

Field Detail

causeback to summary
private Throwable cause

Hides java.lang.Throwable.cause.

exceptionsback to summary
private final List<Throwable> exceptions
messageback to summary
private final String message
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.RuntimeException.serialVersionUID.

Constructor Detail

CompositeExceptionback to summary
public CompositeException(Throwable... exceptions)

Constructs a CompositeException with the given array of Throwables as the list of suppressed exceptions.

Parameters
exceptions:Throwable[]

the Throwables to have as initially suppressed exceptions

Exceptions
IllegalArgumentException:
if exceptions is empty.
CompositeExceptionback to summary
public CompositeException(Iterable<? extends Throwable> errors)

Constructs a CompositeException with the given array of Throwables as the list of suppressed exceptions.

Parameters
errors:Iterable<? extends Throwable>

the Throwables to have as initially suppressed exceptions

Exceptions
IllegalArgumentException:
if errors is empty.

Method Detail

appendStackTraceback to summary
private void appendStackTrace(StringBuilder b, Throwable ex, String prefix)
getCauseback to summary
public synchronized Throwable getCause()

Overrides java.lang.Throwable.getCause.

Doc from java.lang.Throwable.getCause.

Returns the cause of this throwable or null if the cause is nonexistent or unknown. (The cause is the throwable that caused this throwable to get thrown.)

This implementation returns the cause that was supplied via one of the constructors requiring a Throwable, or that was set after creation with the initCause(Throwable) method. While it is typically unnecessary to override this method, a subclass can override it to return a cause set by some other means. This is appropriate for a "legacy chained throwable" that predates the addition of chained exceptions to Throwable. Note that it is not necessary to override any of the PrintStackTrace methods, all of which invoke the getCause method to determine the cause of a throwable.

Returns:Throwable

the cause of this throwable or null if the cause is nonexistent or unknown.

Annotations
@Override
@NonNull
getExceptionsback to summary
public List<Throwable> getExceptions()

Retrieves the list of exceptions that make up the CompositeException.

Returns:List<Throwable>

the exceptions that make up the CompositeException, as a List of Throwables

Annotations
@NonNull
getListOfCausesback to summary
private List<Throwable> getListOfCauses(Throwable ex)
getMessageback to summary
public String getMessage()

Overrides java.lang.Throwable.getMessage.

Doc from java.lang.Throwable.getMessage.

Returns the detail message string of this throwable.

Returns:String

the detail message string of this Throwable instance (which may be null).

Annotations
@Override
@NonNull
getRootCauseback to summary
pack-priv Throwable getRootCause(Throwable e)

Returns the root cause of e. If e.getCause() returns null or e, just return e itself.

Parameters
e:Throwable

the Throwable e.

Returns:Throwable

The root cause of e. If e.getCause() returns null or e, just return e itself.

printStackTraceback to summary
public void printStackTrace()

Overrides java.lang.Throwable.printStackTrace.

All of the following printStackTrace functionality is derived from JDK Throwable printStackTrace. In particular, the 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
Annotations
@Override
printStackTraceback to summary
public void printStackTrace(PrintStream s)

Overrides java.lang.Throwable.printStackTrace.

Doc from java.lang.Throwable.printStackTrace.

Prints this throwable and its backtrace to the specified print stream.

Parameters
s:PrintStream

PrintStream to use for output

Annotations
@Override
printStackTraceback to summary
public void printStackTrace(PrintWriter s)

Overrides java.lang.Throwable.printStackTrace.

Doc from java.lang.Throwable.printStackTrace.

Prints this throwable and its backtrace to the specified print writer.

Parameters
s:PrintWriter

PrintWriter to use for output

Annotations
@Override
printStackTraceback to summary
private void printStackTrace(CompositeException.PrintStreamOrWriter s)

Special handling for printing out a CompositeException. Loops through all inner exceptions and prints them out.

Parameters
s:CompositeException.PrintStreamOrWriter

stream to print to

sizeback to summary
public int size()

Returns the number of suppressed exceptions.

Returns:int

the number of suppressed exceptions

io.reactivex.exceptions back to summary

pack-priv final Class CompositeException.CompositeExceptionCausalChain

extends RuntimeException
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv static final String
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public String
getMessage()

Overrides java.lang.Throwable.getMessage.

Returns the detail message string of this throwable.

Field Detail

MESSAGEback to summary
pack-priv static final String MESSAGE
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.RuntimeException.serialVersionUID.

Constructor Detail

CompositeExceptionCausalChainback to summary
pack-priv CompositeExceptionCausalChain()

Method Detail

getMessageback to summary
public String getMessage()

Overrides java.lang.Throwable.getMessage.

Doc from java.lang.Throwable.getMessage.

Returns the detail message string of this throwable.

Returns:String

the detail message string of this Throwable instance (which may be null).

Annotations
@Override
io.reactivex.exceptions back to summary

pack-priv abstract Class CompositeException.PrintStreamOrWriter

extends Object
Class Inheritance
  • java.lang.Object
  • io.reactivex.exceptions.CompositeException.PrintStreamOrWriter
Known Direct Subclasses
io.reactivex.exceptions.CompositeException.WrappedPrintStream, io.reactivex.exceptions.CompositeException.WrappedPrintWriter

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv abstract void
println(Object o)

Prints the specified string as a line on this StreamOrWriter.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

PrintStreamOrWriterback to summary
pack-priv PrintStreamOrWriter()

Method Detail

printlnback to summary
pack-priv abstract void println(Object o)

Prints the specified string as a line on this StreamOrWriter.

io.reactivex.exceptions back to summary

pack-priv final Class CompositeException.WrappedPrintStream

extends PrintStreamOrWriter
Class Inheritance

Same abstraction and implementation as in JDK to allow PrintStream and PrintWriter to share implementation.

Field Summary

Modifier and TypeField and Description
private final PrintStream

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
println(Object o)

Implements abstract io.reactivex.exceptions.CompositeException.PrintStreamOrWriter.println.

Prints the specified string as a line on this StreamOrWriter.

Field Detail

printStreamback to summary
private final PrintStream printStream

Constructor Detail

WrappedPrintStreamback to summary
pack-priv WrappedPrintStream(PrintStream printStream)

Method Detail

printlnback to summary
pack-priv void println(Object o)

Implements abstract io.reactivex.exceptions.CompositeException.PrintStreamOrWriter.println.

Doc from io.reactivex.exceptions.CompositeException.PrintStreamOrWriter.println.

Prints the specified string as a line on this StreamOrWriter.

Annotations
@Override
io.reactivex.exceptions back to summary

pack-priv final Class CompositeException.WrappedPrintWriter

extends PrintStreamOrWriter
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final PrintWriter

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
println(Object o)

Implements abstract io.reactivex.exceptions.CompositeException.PrintStreamOrWriter.println.

Prints the specified string as a line on this StreamOrWriter.

Field Detail

printWriterback to summary
private final PrintWriter printWriter

Constructor Detail

WrappedPrintWriterback to summary
pack-priv WrappedPrintWriter(PrintWriter printWriter)

Method Detail

printlnback to summary
pack-priv void println(Object o)

Implements abstract io.reactivex.exceptions.CompositeException.PrintStreamOrWriter.println.

Doc from io.reactivex.exceptions.CompositeException.PrintStreamOrWriter.println.

Prints the specified string as a line on this StreamOrWriter.

Annotations
@Override