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 Throwable
A singleton instance of a Throwable indicating a terminal state for exceptions, don't leak this. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
addThrowable
(AtomicReference<Throwable> field, Throwable exception) static NullPointerException
createNullPointerException
(String prefix) Creates a NullPointerException with a composed message vianullWarning(String)
.Returns a flattened list of Throwables from tree-like CompositeException chain.static <T> T
Similar to Objects.requireNonNull but composes the error message vianullWarning(String)
.static String
nullWarning
(String prefix) Composes a String with a null warning message.static Throwable
terminate
(AtomicReference<Throwable> field) Workaround for Java 6 not supporting throwing a final Throwable from a catch block.static String
timeoutMessage
(long timeout, TimeUnit unit) static RuntimeException
wrapOrThrow
(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
-