Class ExceptionHelper
- java.lang.Object
-
- io.reactivex.rxjava3.internal.util.ExceptionHelper
-
public final class ExceptionHelper extends java.lang.ObjectTerminal atomics for Throwable containers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classExceptionHelper.Termination
-
Field Summary
Fields Modifier and Type Field Description static java.lang.ThrowableTERMINATEDA singleton instance of a Throwable indicating a terminal state for exceptions, don't leak this.
-
Constructor Summary
Constructors Modifier Constructor Description privateExceptionHelper()Utility class.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanaddThrowable(java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> field, java.lang.Throwable exception)static java.lang.NullPointerExceptioncreateNullPointerException(java.lang.String prefix)Creates a NullPointerException with a composed message vianullWarning(String).static java.util.List<java.lang.Throwable>flatten(java.lang.Throwable t)Returns a flattened list of Throwables from tree-like CompositeException chain.static <T> TnullCheck(T value, java.lang.String prefix)Similar to Objects.requireNonNull but composes the error message vianullWarning(String).static java.lang.StringnullWarning(java.lang.String prefix)Composes a String with a null warning message.static java.lang.Throwableterminate(java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> field)static <E extends java.lang.Throwable>
java.lang.ExceptionthrowIfThrowable(java.lang.Throwable e)Workaround for Java 6 not supporting throwing a final Throwable from a catch block.static java.lang.StringtimeoutMessage(long timeout, java.util.concurrent.TimeUnit unit)static java.lang.RuntimeExceptionwrapOrThrow(java.lang.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.
-
-
-
Method Detail
-
wrapOrThrow
public static java.lang.RuntimeException wrapOrThrow(java.lang.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.- Parameters:
error- the error to wrap or throw- Returns:
- the (wrapped) error
-
addThrowable
public static boolean addThrowable(java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> field, java.lang.Throwable exception)
-
terminate
public static java.lang.Throwable terminate(java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> field)
-
flatten
public static java.util.List<java.lang.Throwable> flatten(java.lang.Throwable t)
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
public static <E extends java.lang.Throwable> java.lang.Exception throwIfThrowable(java.lang.Throwable e) throws E extends java.lang.ThrowableWorkaround 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 thrownE extends java.lang.Throwable
-
timeoutMessage
public static java.lang.String timeoutMessage(long timeout, java.util.concurrent.TimeUnit unit)
-
nullWarning
public static java.lang.String nullWarning(java.lang.String prefix)
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
public static java.lang.NullPointerException createNullPointerException(java.lang.String prefix)
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
public static <T> T nullCheck(T value, java.lang.String prefix)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:
java.lang.NullPointerException- if value is null- Since:
- 3.0.0
-
-