@ProviderType public class ScopedWorkException extends 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.
| Constructor and Description |
|---|
ScopedWorkException(String message,
Throwable cause,
TransactionContext context)
Creates a new TransactionException with the supplied message and cause
|
| Modifier and Type | Method and Description |
|---|---|
<T extends Throwable> |
as(Class<T> throwable)
Throws the cause of this Exception as a RuntimeException the supplied
Exception type.
|
<A extends Throwable,B extends Throwable> |
asOneOf(Class<A> a,
Class<B> b)
Throws the cause of this Exception as a RuntimeException or one of the
supplied Exception types.
|
<A extends Throwable,B extends Throwable,C extends Throwable> |
asOneOf(Class<A> a,
Class<B> b,
Class<C> c)
Throws the cause of this Exception as a RuntimeException or one of the
supplied Exception types.
|
<A extends Throwable,B extends Throwable,C extends Throwable,D extends Throwable> |
asOneOf(Class<A> a,
Class<B> b,
Class<C> c,
Class<D> d)
Throws the cause of this Exception as a RuntimeException or one of the
supplied Exception types.
|
RuntimeException |
asRuntimeException() |
TransactionContext |
ongoingContext() |
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringpublic ScopedWorkException(String message, Throwable cause, TransactionContext context)
message - cause - context - public TransactionContext ongoingContext()
null otherwise.
Note that this property will not be persisted during serialization.public RuntimeException asRuntimeException()
RuntimeException if it
is one, or this otherwisepublic <T extends Throwable> T as(Class<T> throwable) throws T extends Throwable
Usage is of the form:
public void doStuff() throws IOException {
try {
...
} catch (ScopedWorkException swe) {
throw swe.as(IOException.class);
}
}
throwable - TT extends Throwablepublic <A extends Throwable,B extends Throwable> RuntimeException asOneOf(Class<A> a, Class<B> b) throws A extends Throwable, B extends 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 Throwablepublic <A extends Throwable,B extends Throwable,C extends Throwable> RuntimeException asOneOf(Class<A> a, Class<B> b, Class<C> c) throws A extends Throwable, B extends Throwable, C extends Throwable
a - b - c - ABA extends ThrowableasOneOf(Class, Class)public <A extends Throwable,B extends Throwable,C extends Throwable,D extends Throwable> RuntimeException asOneOf(Class<A> a, Class<B> b, Class<C> c, Class<D> d) throws A extends Throwable, B extends Throwable, C extends Throwable, D extends Throwable
a - b - c - d - ABCDA extends ThrowableasOneOf(Class, Class)Copyright © Contributors to the Eclipse Foundation Licensed under the Eclipse Foundation Specification License – v1.0