Class ExceptionHelper
java.lang.Object
io.reactivex.rxjava3.internal.util.ExceptionHelper
Terminal atomics for Throwable containers.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ThrowableA singleton instance of a Throwable indicating a terminal state for exceptions, don't leak this. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanaddThrowable(AtomicReference<Throwable> field, Throwable exception) static NullPointerExceptioncreateNullPointerException(String prefix) Creates a NullPointerException with a composed message vianullWarning(String).Returns a flattened list of Throwables from tree-like CompositeException chain.static <T> TSimilar to Objects.requireNonNull but composes the error message vianullWarning(String).static StringnullWarning(String prefix) Composes a String with a null warning message.static Throwableterminate(AtomicReference<Throwable> field) Workaround for Java 6 not supporting throwing a final Throwable from a catch block.static StringtimeoutMessage(long timeout, TimeUnit unit) static RuntimeExceptionwrapOrThrow(Throwable error) If the provided Throwable is an Error this method throws it, otherwise returns a RuntimeException wrapping the error if that error is a checked exception.
-
Field Details
-
TERMINATED
A singleton instance of a Throwable indicating a terminal state for exceptions, don't leak this.
-
-
Constructor Details
-
ExceptionHelper
private ExceptionHelper()Utility class.
-
-
Method Details
-
wrapOrThrow
If the provided Throwable is an Error this method throws it, otherwise returns a RuntimeException wrapping the error if that error is a checked exception.- Parameters:
error- the error to wrap or throw- Returns:
- the (wrapped) error
-
addThrowable
-
terminate
-
flatten
Returns a flattened list of Throwables from tree-like CompositeException chain.- Parameters:
t- the starting throwable- Returns:
- the list of Throwables flattened in a depth-first manner
-
throwIfThrowable
Workaround for Java 6 not supporting throwing a final Throwable from a catch block.- Type Parameters:
E- the generic exception type- Parameters:
e- the Throwable error to return or throw- Returns:
- the Throwable e if it is a subclass of Exception
- Throws:
E- the generic exception thrown
-
timeoutMessage
-
nullWarning
Composes a String with a null warning message.- Parameters:
prefix- the prefix to add to the message.- Returns:
- the composed String
- Since:
- 3.0.0
-
createNullPointerException
Creates a NullPointerException with a composed message vianullWarning(String).- Parameters:
prefix- the prefix to add to the message.- Returns:
- the composed String
- Since:
- 3.0.0
-
nullCheck
Similar to Objects.requireNonNull but composes the error message vianullWarning(String).- Type Parameters:
T- the value type- Parameters:
value- the value to checkprefix- the prefix to the error message- Returns:
- the value
- Throws:
NullPointerException- if value is null- Since:
- 3.0.0
-