public class PrintExceptions extends java.lang.Object implements MethodExceptionEventHandler, RuntimeServicesAware
By default this event handler renders an error message containing the class and method which generated
the exception, the exception name and its message.
To render the reference and the location in the template, set the property eventhandler.methodexception.templateinfo
to true
.
To render the stack trace, set the property eventhandler.methodexception.stacktrace
to true
.
Modifier and Type | Field and Description |
---|---|
private RuntimeServices |
rs
Reference to the runtime service
|
private static java.lang.String |
SHOW_STACK_TRACE |
private static java.lang.String |
SHOW_TEMPLATE_INFO |
Constructor and Description |
---|
PrintExceptions() |
Modifier and Type | Method and Description |
---|---|
private static java.lang.String |
getStackTrace(java.lang.Throwable throwable) |
java.lang.Object |
methodException(Context context,
java.lang.Class<?> claz,
java.lang.String method,
java.lang.Exception e,
Info info)
Render the method exception, and optionally the exception message and stack trace.
|
void |
setRuntimeServices(RuntimeServices rs)
Called automatically when event cartridge is initialized.
|
private static java.lang.String SHOW_TEMPLATE_INFO
private static java.lang.String SHOW_STACK_TRACE
private RuntimeServices rs
public java.lang.Object methodException(Context context, java.lang.Class<?> claz, java.lang.String method, java.lang.Exception e, Info info)
methodException
in interface MethodExceptionEventHandler
context
- current contextclaz
- the class of the object the method is being applied tomethod
- the methode
- the thrown exceptioninfo
- template name and line, column informationsprivate static java.lang.String getStackTrace(java.lang.Throwable throwable)
public void setRuntimeServices(RuntimeServices rs)
RuntimeServicesAware
setRuntimeServices
in interface RuntimeServicesAware
rs
- RuntimeServices object assigned during initializationRuntimeServicesAware.setRuntimeServices(org.apache.velocity.runtime.RuntimeServices)