Package rx.exceptions
Class Exceptions
java.lang.Object
rx.exceptions.Exceptions
Utility class with methods to wrap checked exceptions and
manage fatal and regular exception delivery.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidAdds aThrowableto a causality-chain of Throwables, as an additional cause (if it does not already appear in the chain among the causes).static ThrowableGet theThrowableat the end of the causality-chain for a particularThrowablestatic RuntimeExceptionConvenience method to throw aRuntimeExceptionandErrordirectly or wrap any other exception type into aRuntimeException.static voidthrowIfAny(List<? extends Throwable> exceptions) Throws a single or multiple exceptions contained in the collection, wrapping it intoCompositeExceptionif necessary.static voidThrows a particularThrowableonly if it belongs to a set of "fatal" error varieties.static voidthrowOrReport(Throwable t, Observer<?> o) Forwards a fatal exception or reports it to the given Observer.static voidthrowOrReport(Throwable t, Observer<?> o, Object value) Forwards a fatal exception or reports it along with the value caused it to the given Observer.static voidthrowOrReport(Throwable throwable, SingleSubscriber<?> subscriber) Forwards a fatal exception or reports it to the given Observer.
-
Field Details
-
MAX_DEPTH
private static final int MAX_DEPTH- See Also:
-
-
Constructor Details
-
Exceptions
private Exceptions()Utility class, no instances.
-
-
Method Details
-
propagate
Convenience method to throw aRuntimeExceptionandErrordirectly or wrap any other exception type into aRuntimeException.- Parameters:
t- the exception to throw directly or wrapped- Returns:
- because
propagateitself throws an exception or error, this is a sort of phantom return value;propagatedoes not actually return anything
-
throwIfFatal
Throws a particularThrowableonly if it belongs to a set of "fatal" error varieties. These varieties are as follows:OnErrorNotImplementedExceptionOnErrorFailedExceptionOnCompletedFailedExceptionStackOverflowErrorVirtualMachineErrorThreadDeathLinkageError
onErrormethods, 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- theThrowableto test and perhaps throw- See Also:
-
addCause
Adds aThrowableto a causality-chain of Throwables, as an additional cause (if it does not already appear in the chain among the causes).- Parameters:
e- theThrowableat the head of the causality chaincause- theThrowableyou want to add as a cause of the chain
-
getFinalCause
Get theThrowableat the end of the causality-chain for a particularThrowable- Parameters:
e- theThrowablewhose final cause you are curious about- Returns:
- the last
Throwablein the causality-chain ofe(or a "Stack too deep to get final cause"RuntimeExceptionif the chain is too long to traverse)
-
throwIfAny
Throws a single or multiple exceptions contained in the collection, wrapping it intoCompositeExceptionif necessary.- Parameters:
exceptions- 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
-
throwOrReport
Forwards a fatal exception or reports it along with the value caused it to the given Observer.- Parameters:
t- the exceptiono- the observer to report tovalue- the value that caused the exception- Since:
- (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
-
throwOrReport
Forwards a fatal exception or reports it to the given Observer.- Parameters:
t- the exceptiono- the observer to report to- Since:
- (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
-
throwOrReport
Forwards a fatal exception or reports it to the given Observer.- Parameters:
throwable- the exception.subscriber- the subscriber to report to.- Since:
- (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number).
-