public class ExecException extends RuntimeException
When an exception is triggered during an execution, this exception should be thrown.
It should be constructed with the effective ExecContext
at the time of the exception.
All executions are started via ExecController.exec(ExecContext.Supplier, ratpack.func.Action)
.
This exception is caught inside this method, then forward to its context's
ExecContext.error(Exception)
method.
Generally this can all be ignored by user code, particularly request handling. The infrastructure generally manages this mechanism.
Constructor and Description |
---|
ExecException(ExecContext context,
Throwable exception)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
forward()
Route the exception the the context.
|
ExecContext |
getContext()
The execution context at the time that the exception occurred.
|
static ExecException |
wrap(ExecContext context,
Throwable throwable)
Converts, if necessary, the given
throwable into an ExecException . |
static void |
wrapAndForward(ExecContext context,
Throwable throwable)
Calls
wrap(ExecContext, Throwable) then forward() . |
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
public ExecException(ExecContext context, Throwable exception)
context
- the execution context at the time the exception occurredexception
- the real exceptionpublic ExecContext getContext()
public static ExecException wrap(ExecContext context, Throwable throwable)
throwable
into an ExecException
.
If the throwable
is an ExecException
, it is returned as is.
This method should be used when catching/thrown exceptions by infrastructure. The return value should be immediately thrown.
context
- the execution context at thethrowable
- the exception to possibly wrappublic void forward()
public static void wrapAndForward(ExecContext context, Throwable throwable)
wrap(ExecContext, Throwable)
then forward()
.context
- the execution context at thethrowable
- the exception to possibly wrap