Top Description Inners Fields Constructors Methods
rx.exceptions

public final Class CompositeException

extends RuntimeException
Class Inheritance
Imports
java.io.*, java.util.*

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(String
the prefix to use (actually unused)
messagePrefix
,
Collection<? extends Throwable>
the collection of errors
errors
)

Deprecated please use CompositeException(Collection)
Constructs a CompositeException with the given prefix and error collection.
public
CompositeException(Collection<? extends Throwable>
the collection of errors
errors
)

Constructs a CompositeException instance with the Throwable elements of the supplied Collection.

public
CompositeException(Throwable...
the array of Throwables
errors
)

Constructs a CompositeException instance with the supplied initial Throwables.

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.
private 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.

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(String messagePrefix, Collection<? extends Throwable> errors)

Deprecated

please use CompositeException(Collection)

Constructs a CompositeException with the given prefix and error collection.

Parameters
messagePrefix:String

the prefix to use (actually unused)

errors:Collection<? extends Throwable>

the collection of errors

Annotations
@Deprecated
CompositeExceptionback to summary
public CompositeException(Collection<? extends Throwable> errors)

Constructs a CompositeException instance with the Throwable elements of the supplied Collection.

Null values are replaced by NullPointerException.

Parameters
errors:Collection<? extends Throwable>

the collection of errors

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

Constructs a CompositeException instance with the supplied initial Throwables.

Parameters
errors:Throwable[]

the array of Throwables

Since
1.3

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

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
getRootCauseback to summary
private 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

rx.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
rx.exceptions back to summary

pack-priv abstract Class CompositeException.PrintStreamOrWriter

extends Object
Class Inheritance
Known Direct Subclasses
rx.exceptions.CompositeException.WrappedPrintStream, rx.exceptions.CompositeException.WrappedPrintWriter

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv abstract Object
lock()

Returns the object to be locked when using this StreamOrWriter

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

lockback to summary
pack-priv abstract Object lock()

Returns the object to be locked when using this StreamOrWriter

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

Prints the specified string as a line on this StreamOrWriter

rx.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 Object
lock()

Implements abstract rx.exceptions.CompositeException.PrintStreamOrWriter.lock.

Returns the object to be locked when using this StreamOrWriter
pack-priv void
println(Object o)

Implements abstract rx.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

lockback to summary
pack-priv Object lock()

Implements abstract rx.exceptions.CompositeException.PrintStreamOrWriter.lock.

Doc from rx.exceptions.CompositeException.PrintStreamOrWriter.lock.

Returns the object to be locked when using this StreamOrWriter

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

Implements abstract rx.exceptions.CompositeException.PrintStreamOrWriter.println.

Doc from rx.exceptions.CompositeException.PrintStreamOrWriter.println.

Prints the specified string as a line on this StreamOrWriter

Annotations
@Override
rx.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 Object
lock()

Implements abstract rx.exceptions.CompositeException.PrintStreamOrWriter.lock.

Returns the object to be locked when using this StreamOrWriter
pack-priv void
println(Object o)

Implements abstract rx.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

lockback to summary
pack-priv Object lock()

Implements abstract rx.exceptions.CompositeException.PrintStreamOrWriter.lock.

Doc from rx.exceptions.CompositeException.PrintStreamOrWriter.lock.

Returns the object to be locked when using this StreamOrWriter

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

Implements abstract rx.exceptions.CompositeException.PrintStreamOrWriter.println.

Doc from rx.exceptions.CompositeException.PrintStreamOrWriter.println.

Prints the specified string as a line on this StreamOrWriter

Annotations
@Override