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 the exception name only. To include both the exception name and the message, set the property
eventhandler.methodexception.messagetotrue. To render the stack trace, set the propertyeventhandler.methodexception.stacktracetotrue.- Since:
- 1.5
- Version:
- $Id: PrintExceptions.java 685685 2008-08-13 21:43:27Z nbubna $
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.velocity.app.event.MethodExceptionEventHandler
MethodExceptionEventHandler.MethodExceptionExecutor
-
-
Field Summary
Fields Modifier and Type Field Description private RuntimeServicesrsReference to the runtime serviceprivate static java.lang.StringSHOW_MESSAGEprivate static java.lang.StringSHOW_STACK_TRACE
-
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.StringgetStackTrace(java.lang.Throwable throwable)java.lang.ObjectmethodException(java.lang.Class claz, java.lang.String method, java.lang.Exception e)Render the method exception, and optionally the exception message and stack trace.voidsetRuntimeServices(RuntimeServices rs)Called automatically when event cartridge is initialized.
-
-
-
Field Detail
-
SHOW_MESSAGE
private static java.lang.String SHOW_MESSAGE
-
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(java.lang.Class claz, java.lang.String method, java.lang.Exception e) throws java.lang.ExceptionRender the method exception, and optionally the exception message and stack trace.- Specified by:
methodExceptionin interfaceMethodExceptionEventHandler- Parameters:
claz- the class of the object the method is being applied tomethod- the methode- the thrown exception- Returns:
- an object to insert in the page
- Throws:
java.lang.Exception- an exception to be thrown instead inserting an object
-
getStackTrace
private static java.lang.String getStackTrace(java.lang.Throwable throwable)
-
setRuntimeServices
public void setRuntimeServices(RuntimeServices rs)
Description copied from interface:RuntimeServicesAwareCalled automatically when event cartridge is initialized.- Specified by:
setRuntimeServicesin interfaceRuntimeServicesAware- Parameters:
rs- RuntimeServices object assigned during initialization- See Also:
RuntimeServicesAware.setRuntimeServices(org.apache.velocity.runtime.RuntimeServices)
-
-