public abstract class Exceptions
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static boolean |
CANCEL_STACKTRACE |
static java.lang.Throwable |
TERMINATED
A singleton instance of a Throwable indicating a terminal state for exceptions, don't leak this!
|
Modifier and Type | Method and Description |
---|---|
static <T> boolean |
addThrowable(java.util.concurrent.atomic.AtomicReferenceFieldUpdater<T,java.lang.Throwable> field,
T instance,
java.lang.Throwable exception) |
static java.lang.NullPointerException |
argumentIsNullException() |
static java.lang.RuntimeException |
bubble(java.lang.Throwable t)
Return an unchecked
RuntimeException to be thrown that will bubble upstream. |
static java.lang.IllegalStateException |
duplicateOnSubscribeException() |
static java.lang.RuntimeException |
failWithCancel()
An exception that is propagated upward and considered as "fatal" as per Reactive Stream limited list of
exceptions allowed to bubble.
|
static java.lang.IllegalStateException |
failWithOverflow()
Return an
IllegalStateException |
static boolean |
isBubbling(java.lang.Throwable t)
Check if the given error is a bubbled wrapped exception.
|
static boolean |
isCancel(java.lang.Throwable t)
Check if the given error is a cancel signal.
|
static java.lang.IllegalArgumentException |
nullOrNegativeRequestException(long elements) |
static java.lang.RuntimeException |
propagate(java.lang.Throwable t)
Return an unchecked
RuntimeException to be thrown that will be propagated
downstream through Subscriber.onError(Throwable) . |
static <T> java.lang.Throwable |
terminate(java.util.concurrent.atomic.AtomicReferenceFieldUpdater<T,java.lang.Throwable> field,
T instance)
Atomic utility to safely mark a volatile throwable reference with a terminal marker.
|
static void |
throwIfFatal(java.lang.Throwable t)
Throws a particular
Throwable only if it belongs to a set of "fatal" error varieties. |
static java.lang.Throwable |
unwrap(java.lang.Throwable t)
Unwrap a particular
Throwable only if it is a wrapped exception via
bubble(java.lang.Throwable) or propagate(java.lang.Throwable) . |
public static final boolean CANCEL_STACKTRACE
public static final java.lang.Throwable TERMINATED
public static <T> boolean addThrowable(java.util.concurrent.atomic.AtomicReferenceFieldUpdater<T,java.lang.Throwable> field, T instance, java.lang.Throwable exception)
T
- the parent instance typefield
- the target field updaterinstance
- the parent instance for the fieldexception
- the Throwable to add.TERMINATED
instance.public static java.lang.NullPointerException argumentIsNullException()
NullPointerException
with a cause message abiding to reactive stream specification.public static java.lang.RuntimeException bubble(java.lang.Throwable t)
RuntimeException
to be thrown that will bubble upstream.
This method invokes throwIfFatal(Throwable)
.
t
- the root causepublic static java.lang.IllegalStateException duplicateOnSubscribeException()
IllegalStateException
with a cause message abiding to reactive stream specification.public static java.lang.RuntimeException failWithCancel()
RuntimeException
that can be checked via isCancel(java.lang.Throwable)
public static java.lang.IllegalStateException failWithOverflow()
IllegalStateException
IllegalStateException
public static boolean isCancel(java.lang.Throwable t)
t
- the Throwable
error to checkpublic static boolean isBubbling(java.lang.Throwable t)
t
- the Throwable
error to checkpublic static java.lang.IllegalArgumentException nullOrNegativeRequestException(long elements)
elements
- the invalid requested demandIllegalArgumentException
with a cause message abiding to reactive stream specification.public static java.lang.RuntimeException propagate(java.lang.Throwable t)
RuntimeException
to be thrown that will be propagated
downstream through Subscriber.onError(Throwable)
.
This method invokes throwIfFatal(Throwable)
.
t
- the root causepublic static <T> java.lang.Throwable terminate(java.util.concurrent.atomic.AtomicReferenceFieldUpdater<T,java.lang.Throwable> field, T instance)
T
- the instance typefield
- the atomic containerinstance
- the reference instancepublic static void throwIfFatal(java.lang.Throwable t)
Throwable
only if it belongs to a set of "fatal" error varieties. These
varieties are as follows:
BubblingException
StackOverflowError
VirtualMachineError
ThreadDeath
LinkageError
t
- the exception to evaluatepublic static java.lang.Throwable unwrap(java.lang.Throwable t)
Throwable
only if it is a wrapped exception via
bubble(java.lang.Throwable)
or propagate(java.lang.Throwable)
.t
- the exception to wrap