Throwable e)
{
try
{
// get a velocity context
Context ctx = createContext(request, response);
Throwable cause = e;
// if it's an MIE, i want the real cause and stack trace!
if (cause instanceof MethodInvocationException)
{
// put the invocation exception in the context
ctx.put(KEY_ERROR_INVOCATION_EXCEPTION, e);
// get the real cause
cause = ((MethodInvocationException)e).getWrappedThrowable();
}
// add the cause to the context
ctx.put(KEY_ERROR_CAUSE, cause);
// grab the cause's stack trace and put it in the context
StringWriter sw = new StringWriter();
cause.printStackTrace(new java.io.PrintWriter(sw));
ctx.put(KEY_ERROR_STACKTRACE, sw.toString());
// retrieve and render the error template
Template et = getTemplate(errorTemplate);
mergeTemplate(et, ctx, response);