Class PrintExceptions
java.lang.Object
org.apache.velocity.app.event.implement.PrintExceptions
- All Implemented Interfaces:
EventHandler
,MethodExceptionEventHandler
,RuntimeServicesAware
public class PrintExceptions
extends 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.message
to true
. To render
the stack trace, set the property eventhandler.methodexception.stacktrace
to true
.
- 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
FieldsModifier and TypeFieldDescriptionprivate RuntimeServices
Reference to the runtime serviceprivate static String
private static String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static String
getStackTrace
(Throwable throwable) methodException
(Class claz, String method, Exception e) Render the method exception, and optionally the exception message and stack trace.void
Called automatically when event cartridge is initialized.
-
Field Details
-
SHOW_MESSAGE
-
SHOW_STACK_TRACE
-
rs
Reference to the runtime service
-
-
Constructor Details
-
PrintExceptions
public PrintExceptions()
-
-
Method Details
-
methodException
Render the method exception, and optionally the exception message and stack trace.- Specified by:
methodException
in 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:
Exception
- an exception to be thrown instead inserting an object
-
getStackTrace
-
setRuntimeServices
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:
-