Package org.apache.velocity.app.event.implement

# 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 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`.

Since:
  1.5
Version:
  $Id$
Author:
  Will Glass-Husain, Claude Brisson

## Constructor Summary

Constructors
Constructor
Description
`PrintExceptions()`

## Method Summary

Modifier and Type
Method
Description
`Object`
`methodException(Context context, Class<?> claz, String method, 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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### PrintExceptions

public PrintExceptions()

## Method Details

### methodException

public Object methodException(Context context, Class<?> claz, String method, Exception e, Info info)
Render the method exception, and optionally the exception message and stack trace.

Specified by:
  `methodException` in interface `MethodExceptionEventHandler`
Parameters:
  `context` - current context
  `claz` - the class of the object the method is being applied to
  `method` - the method
  `e` - the thrown exception
  `info` - template name and line, column informations
Returns:
  an object to insert in the page

### setRuntimeServices

public void setRuntimeServices(RuntimeServices rs)
Description copied from interface: `RuntimeServicesAware`
Called automatically when event cartridge is initialized.

Specified by:
  `setRuntimeServices` in interface `RuntimeServicesAware`
Parameters:
  `rs` - RuntimeServices object assigned during initialization
See Also:
  - `RuntimeServicesAware.setRuntimeServices(org.apache.velocity.runtime.RuntimeServices)`