Class PrintExceptions
- java.lang.Object
-
- org.apache.velocity.app.event.implement.PrintExceptions
-
- All Implemented Interfaces:
EventHandler
,MethodExceptionEventHandler
,RuntimeServicesAware
public class PrintExceptions extends java.lang.Object implements MethodExceptionEventHandler, RuntimeServicesAware
Simple event handler that renders method exceptions in the page rather than throwing the exception. Useful for debugging.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
totrue
. To render the stack trace, set the propertyeventhandler.methodexception.stacktrace
totrue
.- Since:
- 1.5
- Version:
- $Id$
-
-
Field Summary
Fields Modifier and Type Field Description private RuntimeServices
rs
Reference to the runtime serviceprivate static java.lang.String
SHOW_STACK_TRACE
private static java.lang.String
SHOW_TEMPLATE_INFO
-
Constructor Summary
Constructors Constructor Description PrintExceptions()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Field Detail
-
SHOW_TEMPLATE_INFO
private static java.lang.String SHOW_TEMPLATE_INFO
-
SHOW_STACK_TRACE
private static java.lang.String SHOW_STACK_TRACE
-
rs
private RuntimeServices rs
Reference to the runtime service
-
-
Method Detail
-
methodException
public 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.- Specified by:
methodException
in interfaceMethodExceptionEventHandler
- Parameters:
context
- current contextclaz
- the class of the object the method is being applied tomethod
- the methode
- the thrown exceptioninfo
- template name and line, column informations- Returns:
- an object to insert in the page
-
getStackTrace
private static java.lang.String getStackTrace(java.lang.Throwable throwable)
-
setRuntimeServices
public void setRuntimeServices(RuntimeServices rs)
Description copied from interface:RuntimeServicesAware
Called automatically when event cartridge is initialized.- Specified by:
setRuntimeServices
in interfaceRuntimeServicesAware
- Parameters:
rs
- RuntimeServices object assigned during initialization- See Also:
RuntimeServicesAware.setRuntimeServices(org.apache.velocity.runtime.RuntimeServices)
-
-