@ProviderType
public class ScopedWorkException
extends java.lang.RuntimeException
Exception.
If the scope was inherited and therefore is still active when this exception
is raised then the current TransactionContext will be available from
the ongoingContext() method.
| Modifier and Type | Field and Description |
|---|---|
private TransactionContext |
context
TransactionContext instances are not required to
be Serializable, and the ongoing context is very
unlikely to be active post deserialization. |
private static long |
serialVersionUID |
| Constructor and Description |
|---|
ScopedWorkException(java.lang.String message,
java.lang.Throwable cause,
TransactionContext context)
Creates a new TransactionException with the supplied message and cause
|
| Modifier and Type | Method and Description |
|---|---|
<T extends java.lang.Throwable> |
as(java.lang.Class<T> throwable)
Throws the cause of this Exception as a RuntimeException the supplied
Exception type.
|
<A extends java.lang.Throwable,B extends java.lang.Throwable> |
asOneOf(java.lang.Class<A> a,
java.lang.Class<B> b)
Throws the cause of this Exception as a RuntimeException or one of the
supplied Exception types.
|
<A extends java.lang.Throwable,B extends java.lang.Throwable,C extends java.lang.Throwable> |
asOneOf(java.lang.Class<A> a,
java.lang.Class<B> b,
java.lang.Class<C> c)
Throws the cause of this Exception as a RuntimeException or one of the
supplied Exception types.
|
<A extends java.lang.Throwable,B extends java.lang.Throwable,C extends java.lang.Throwable,D extends java.lang.Throwable> |
asOneOf(java.lang.Class<A> a,
java.lang.Class<B> b,
java.lang.Class<C> c,
java.lang.Class<D> d)
Throws the cause of this Exception as a RuntimeException or one of the
supplied Exception types.
|
java.lang.RuntimeException |
asRuntimeException() |
TransactionContext |
ongoingContext() |
private static <E extends java.lang.Throwable> |
throwCause(java.lang.Throwable e) |
private static final long serialVersionUID
private final transient TransactionContext context
TransactionContext instances are not required to
be Serializable, and the ongoing context is very
unlikely to be active post deserialization. As a result
this field is transient.public ScopedWorkException(java.lang.String message,
java.lang.Throwable cause,
TransactionContext context)
message - cause - context - public TransactionContext ongoingContext()
null otherwise.
Note that this property will not be persisted during serialization.public java.lang.RuntimeException asRuntimeException()
RuntimeException if it
is one, or this otherwisepublic <T extends java.lang.Throwable> T as(java.lang.Class<T> throwable)
throws T extends java.lang.Throwable
Usage is of the form:
public void doStuff() throws IOException {
try {
...
} catch (ScopedWorkException swe) {
throw swe.as(IOException.class);
}
}
throwable - TT extends java.lang.Throwablepublic <A extends java.lang.Throwable,B extends java.lang.Throwable> java.lang.RuntimeException asOneOf(java.lang.Class<A> a,
java.lang.Class<B> b)
throws A extends java.lang.Throwable,
B extends java.lang.Throwable
Usage is of the form:
public void doStuff() throws IOException, ClassNotFoundException {
try {
...
} catch (ScopedWorkException swe) {
throw swe.asOneOf(IOException.class, ClassNotFoundException.class);
}
}
a - b - ABA extends java.lang.Throwablepublic <A extends java.lang.Throwable,B extends java.lang.Throwable,C extends java.lang.Throwable> java.lang.RuntimeException asOneOf(java.lang.Class<A> a,
java.lang.Class<B> b,
java.lang.Class<C> c)
throws A extends java.lang.Throwable,
B extends java.lang.Throwable,
C extends java.lang.Throwable
a - b - c - ABA extends java.lang.ThrowableasOneOf(Class, Class)public <A extends java.lang.Throwable,B extends java.lang.Throwable,C extends java.lang.Throwable,D extends java.lang.Throwable> java.lang.RuntimeException asOneOf(java.lang.Class<A> a,
java.lang.Class<B> b,
java.lang.Class<C> c,
java.lang.Class<D> d)
throws A extends java.lang.Throwable,
B extends java.lang.Throwable,
C extends java.lang.Throwable,
D extends java.lang.Throwable
a - b - c - d - ABCDA extends java.lang.ThrowableasOneOf(Class, Class)private static <E extends java.lang.Throwable> java.lang.RuntimeException throwCause(java.lang.Throwable e)
throws E extends java.lang.Throwable
E extends java.lang.Throwable