Top Description Fields Constructors Methods
rx.exceptions

public final Class Exceptions

extends Object
Class Inheritance
Imports
java.util.*, rx.Observer, .SingleSubscriber

Utility class with methods to wrap checked exceptions and manage fatal and regular exception delivery.

Field Summary

Modifier and TypeField and Description
private static final int

Constructor Summary

AccessConstructor and Description
private
Exceptions()

Utility class, no instances.

Method Summary

Modifier and TypeMethod and Description
public static void
addCause(Throwable
the Throwable at the head of the causality chain
e
,
Throwable
the Throwable you want to add as a cause of the chain
cause
)

Adds a Throwable to a causality-chain of Throwables, as an additional cause (if it does not already appear in the chain among the causes).

public static Throwable

Returns:

the last Throwable in the causality-chain of e (or a "Stack too deep to get final cause" RuntimeException if the chain is too long to traverse)
getFinalCause
(Throwable
the Throwable whose final cause you are curious about
e
)

Get the Throwable at the end of the causality-chain for a particular Throwable

public static RuntimeException

Returns:

because propagate itself throws an exception or error, this is a sort of phantom return value; propagate does not actually return anything
propagate
(Throwable
the exception to throw directly or wrapped
t
)

Convenience method to throw a RuntimeException and Error directly or wrap any other exception type into a RuntimeException.

public static void
throwIfAny(List<? extends Throwable>
the collection of exceptions. If null or empty, no exception is thrown. If the collection contains a single exception, that exception is either thrown as-is or wrapped into a CompositeException. Multiple exceptions are wrapped into a CompositeException.
exceptions
)

Throws a single or multiple exceptions contained in the collection, wrapping it into CompositeException if necessary.

public static void
throwIfFatal(Throwable
the Throwable to test and perhaps throw
t
)

Throws a particular Throwable only if it belongs to a set of "fatal" error varieties.

public static void
throwOrReport(Throwable
the exception
t
,
Observer<?>
the observer to report to
o
,
Object
the value that caused the exception
value
)

Forwards a fatal exception or reports it along with the value caused it to the given Observer.

public static void
throwOrReport(Throwable
the exception
t
,
SingleSubscriber<?>
the observer to report to
o
,
Object
the value that caused the exception
value
)

Forwards a fatal exception or reports it along with the value caused it to the given SingleSubscriber.

public static void
throwOrReport(Throwable
the exception
t
,
Observer<?>
the observer to report to
o
)

Forwards a fatal exception or reports it to the given Observer.

public static void
throwOrReport(Throwable
the exception.
throwable
,
SingleSubscriber<?>
the subscriber to report to.
subscriber
)

Forwards a fatal exception or reports it to the given Observer.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

MAX_DEPTHback to summary
private static final int MAX_DEPTH

Constructor Detail

Exceptionsback to summary
private Exceptions()

Utility class, no instances.

Method Detail

addCauseback to summary
public static void addCause(Throwable e, Throwable cause)

Adds a Throwable to a causality-chain of Throwables, as an additional cause (if it does not already appear in the chain among the causes).

Parameters
e:Throwable

the Throwable at the head of the causality chain

cause:Throwable

the Throwable you want to add as a cause of the chain

getFinalCauseback to summary
public static Throwable getFinalCause(Throwable e)

Get the Throwable at the end of the causality-chain for a particular Throwable

Parameters
e:Throwable

the Throwable whose final cause you are curious about

Returns:Throwable

the last Throwable in the causality-chain of e (or a "Stack too deep to get final cause" RuntimeException if the chain is too long to traverse)

propagateback to summary
public static RuntimeException propagate(Throwable t)

Convenience method to throw a RuntimeException and Error directly or wrap any other exception type into a RuntimeException.

Parameters
t:Throwable

the exception to throw directly or wrapped

Returns:RuntimeException

because propagate itself throws an exception or error, this is a sort of phantom return value; propagate does not actually return anything

throwIfAnyback to summary
public static void throwIfAny(List<? extends Throwable> exceptions)

Throws a single or multiple exceptions contained in the collection, wrapping it into CompositeException if necessary.

Parameters
exceptions:List<? extends Throwable>

the collection of exceptions. If null or empty, no exception is thrown. If the collection contains a single exception, that exception is either thrown as-is or wrapped into a CompositeException. Multiple exceptions are wrapped into a CompositeException.

Since
1.1.0
throwIfFatalback to summary
public static void throwIfFatal(Throwable t)

Throws a particular Throwable only if it belongs to a set of "fatal" error varieties. These varieties are as follows:

This can be useful if you are writing an operator that calls user-supplied code, and you want to notify subscribers of errors encountered in that code by calling their onError methods, but only if the errors are not so catastrophic that such a call would be futile, in which case you simply want to rethrow the error.
Parameters
t:Throwable

the Throwable to test and perhaps throw

See Also
RxJava: StackOverflowError is swallowed (Issue #748)
throwOrReportback to summary
public static void throwOrReport(Throwable t, Observer<?> o, Object value)

Forwards a fatal exception or reports it along with the value caused it to the given Observer.

Parameters
t:Throwable

the exception

o:Observer<?>

the observer to report to

value:Object

the value that caused the exception

Since
1.3
throwOrReportback to summary
public static void throwOrReport(Throwable t, SingleSubscriber<?> o, Object value)

Forwards a fatal exception or reports it along with the value caused it to the given SingleSubscriber.

Parameters
t:Throwable

the exception

o:SingleSubscriber<?>

the observer to report to

value:Object

the value that caused the exception

Since
1.3
throwOrReportback to summary
public static void throwOrReport(Throwable t, Observer<?> o)

Forwards a fatal exception or reports it to the given Observer.

Parameters
t:Throwable

the exception

o:Observer<?>

the observer to report to

Since
1.3
throwOrReportback to summary
public static void throwOrReport(Throwable throwable, SingleSubscriber<?> subscriber)

Forwards a fatal exception or reports it to the given Observer.

Parameters
throwable:Throwable

the exception.

subscriber:SingleSubscriber<?>

the subscriber to report to.

Since
1.3