public final class

CompositeException

extends RuntimeException
java.lang.Object
   ↳ java.lang.Throwable
     ↳ java.lang.Exception
       ↳ java.lang.RuntimeException
         ↳ io.reactivex.exceptions.CompositeException

Class Overview

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.

Summary

Public Constructors
CompositeException(Throwable... exceptions)
Constructs a CompositeException with the given array of Throwables as the list of suppressed exceptions.
CompositeException(Iterable<? extends Throwable> errors)
Constructs a CompositeException with the given array of Throwables as the list of suppressed exceptions.
Public Methods
synchronized Throwable getCause()
List<Throwable> getExceptions()
Retrieves the list of exceptions that make up the CompositeException.
String getMessage()
void printStackTrace()
All of the following printStackTrace functionality is derived from JDK Throwable printStackTrace.
void printStackTrace(PrintWriter s)
void printStackTrace(PrintStream s)
int size()
Returns the number of suppressed exceptions.
[Expand]
Inherited Methods
From class java.lang.Throwable
From class java.lang.Object

Public Constructors

public CompositeException (Throwable... exceptions)

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 if exceptions is empty.

public CompositeException (Iterable<? extends Throwable> errors)

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 if errors is empty.

Public Methods

public synchronized Throwable getCause ()

public List<Throwable> getExceptions ()

Retrieves the list of exceptions that make up the CompositeException.

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

public String getMessage ()

public void 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

public void printStackTrace (PrintWriter s)

public void printStackTrace (PrintStream s)

public int size ()

Returns the number of suppressed exceptions.

Returns
  • the number of suppressed exceptions