public void printStackTrace(PrintWriter s) { super.printStackTrace(s); if (exception != null) { s.write("\n\nWrapped Exception:\n\n"); if (exception.getCause()!=null) exception.getCause().printStackTrace(s); else if (exception instanceof org.hibernate.JDBCException) { (((JDBCException) exception).getSQLException()).printStackTrace(s); } else if (exception instanceof MethodInvocationException) { (((MethodInvocationException) exception).getWrappedThrowable()).printStackTrace(s); } else if (exception instanceof ServletException) { (((ServletException) exception).getRootCause()).printStackTrace(s); } else { exception.printStackTrace(s); } } }
public void printStackTrace(PrintStream s) { super.printStackTrace(s); if (exception != null) { s.print("\n\nWrapped Exception:\n\n"); if (exception.getCause()!=null) exception.getCause().printStackTrace(s); else if (exception instanceof org.hibernate.JDBCException) { (((JDBCException) exception).getSQLException()).printStackTrace(s); } else if (exception instanceof MethodInvocationException) { (((MethodInvocationException) exception).getWrappedThrowable()).printStackTrace(s); } else if (exception instanceof ServletException) { (((ServletException) exception).getRootCause()).printStackTrace(s); } else { exception.printStackTrace(s); } } }
private void exceptionHandling(final Writer writer, Exception e, final String templateDirectory, String template) throws IOException { if (e instanceof ResourceNotFoundException) { log.error("ResourceNotFoundException occurred whilst loading resource " + template); URL templateUrl = ClassLoaderUtils.getResource(templateDirectory + template, this.getClass()); if (templateUrl == null) { throw new VelocityException("Could not find template '" + templateDirectory + template + "' ensure it is in the classpath."); } writer.write("Could not locate resource " + templateDirectory + template); } else if (e instanceof MethodInvocationException) { Throwable t = ((MethodInvocationException) e).getWrappedThrowable(); log.error("MethodInvocationException occurred getting message body from Velocity: " + t, t); writer.write(getErrorMessageForException(e)); } else { log.error("Exception getting message body from Velocity: " + e, e); writer.write(getErrorMessageForException(e)); } }
Throwable wrapped = mie.getWrappedThrowable();
throw e.getCause(); } catch (MethodInvocationException e) { Throwable wrappedThrowable = e.getWrappedThrowable(); if (wrappedThrowable instanceof MissingParamsException) { MissingParamsException missingParamsException = (MissingParamsException) wrappedThrowable;
writer.flush(); } catch (MethodInvocationException e) { Throwable cause = e.getWrappedThrowable(); if (cause instanceof Exception) throw (Exception) cause; if (cause instanceof Error) throw (Error) cause;
Throwable wrapped = mie.getWrappedThrowable();
System.out.println(" method = " + mie.getMethodName() ); Throwable t = mie.getWrappedThrowable(); System.out.println(" throwable = " + t ); System.out.println(" method = " + mie.getMethodName() ); Throwable t = mie.getWrappedThrowable(); System.out.println(" throwable = " + t ); System.out.println(" method = " + mie.getMethodName() ); Throwable t = mie.getWrappedThrowable(); System.out.println(" throwable = " + t ); System.out.println(" method = " + mie.getMethodName() ); Throwable t = mie.getWrappedThrowable(); System.out.println(" throwable = " + t );
/** * Merge the template with the context. * Can be overridden to customize the behavior. * @param template the template to merge * @param context the Velocity context to use for rendering * @param response servlet response (use this to get the OutputStream or Writer) * @throws Exception if thrown by Velocity * @see Template#merge */ protected void mergeTemplate( Template template, Context context, HttpServletResponse response) throws Exception { try { template.merge(context, response.getWriter()); } catch (MethodInvocationException ex) { Throwable cause = ex.getWrappedThrowable(); throw new NestedServletException( "Method invocation failed during rendering of Velocity view with name '" + getBeanName() + "': " + ex.getMessage() + "; reference [" + ex.getReferenceName() + "], method '" + ex.getMethodName() + "'", cause==null ? ex : cause); } }
throw new BuildException("Exception thrown by '" + e.getReferenceName() + "." + e.getMethodName() +"'", e.getWrappedThrowable()); } catch(ParseErrorException e) { throw new BuildException("Velocity syntax error", e);
/** * Merge the template with the context. * Can be overridden to customize the behavior. * @param template the template to merge * @param context the Velocity context to use for rendering * @param response servlet response (use this to get the OutputStream or Writer) * @throws Exception if thrown by Velocity * @see org.apache.velocity.Template#merge */ protected void mergeTemplate( Template template, Context context, HttpServletResponse response) throws Exception { try { template.merge(context, response.getWriter()); } catch (MethodInvocationException ex) { Throwable cause = ex.getWrappedThrowable(); throw new NestedServletException( "Method invocation failed during rendering of Velocity view with name '" + getBeanName() + "': " + ex.getMessage() + "; reference [" + ex.getReferenceName() + "], method '" + ex.getMethodName() + "'", cause==null ? ex : cause); } }
/** * Merge the template with the context. * Can be overridden to customize the behavior. * @param template the template to merge * @param context the Velocity context to use for rendering * @param response servlet response (use this to get the OutputStream or Writer) * @throws Exception if thrown by Velocity * @see Template#merge */ protected void mergeTemplate( Template template, Context context, HttpServletResponse response) throws Exception { try { template.merge(context, response.getWriter()); } catch (MethodInvocationException ex) { Throwable cause = ex.getWrappedThrowable(); throw new NestedServletException( "Method invocation failed during rendering of Velocity view with name '" + getBeanName() + "': " + ex.getMessage() + "; reference [" + ex.getReferenceName() + "], method '" + ex.getMethodName() + "'", cause==null ? ex : cause); } }
"Exception thrown by '" + e.getReferenceName() + "." + e.getMethodName() +"'" + ERR_MSG_FRAGMENT, e.getWrappedThrowable());
"Exception thrown by '" + e.getReferenceName() + "." + e.getMethodName() +"'" + ERR_MSG_FRAGMENT, e.getWrappedThrowable());
"Exception thrown by '" + e.getReferenceName() + "." + e.getMethodName() +"'" + ERR_MSG_FRAGMENT, e.getWrappedThrowable());