You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by dl...@apache.org on 2002/07/03 23:14:59 UTC
cvs commit: jakarta-velocity/src/java/org/apache/velocity/servlet VelocityServlet.java
dlr 2002/07/03 14:14:59
Modified: src/java/org/apache/velocity/servlet VelocityServlet.java
Log:
o Include a title of "Error" in the HTML output.
o Don't append the cause directly, lest we output duplicate info:
VelocityServlet : Error processing the template
org.apache.velocity.exception.VelocityException
org.apache.velocity.exception.VelocityException
at org.tigris.eyebrowse.servlets.EyebrowseServlet.handleRequest(Unknown Source)
at org.apache.velocity.servlet.VelocityServlet.doRequest(VelocityServlet.java:372)
...
Instead, extract the message and use that (if there is one). The
stack trace is still always appended, and includes the class type of
the exception thrown.
Revision Changes Path
1.47 +9 -6 jakarta-velocity/src/java/org/apache/velocity/servlet/VelocityServlet.java
Index: VelocityServlet.java
===================================================================
RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/servlet/VelocityServlet.java,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -u -r1.46 -r1.47
--- VelocityServlet.java 3 Apr 2002 16:36:00 -0000 1.46
+++ VelocityServlet.java 3 Jul 2002 21:14:59 -0000 1.47
@@ -403,7 +403,6 @@
*/
Template template = handleRequest( request, response, context );
-
/*
* bail if we can't find the template
*/
@@ -668,16 +667,21 @@
* @param response HttpServletResponse object from servlet container.
* @param cause Exception that was thrown by some other part of process.
*/
- protected void error( HttpServletRequest request, HttpServletResponse response, Exception cause )
+ protected void error( HttpServletRequest request, HttpServletResponse response, Exception cause )
throws ServletException, IOException
{
StringBuffer html = new StringBuffer();
html.append("<html>");
+ html.append("<title>Error</title>");
html.append("<body bgcolor=\"#ffffff\">");
html.append("<h2>VelocityServlet : Error processing the template</h2>");
html.append("<pre>");
- html.append( cause );
- html.append("<br>");
+ String why = cause.getMessage();
+ if (why != null && why.trim().length() > 0)
+ {
+ html.append(why);
+ html.append("<br>");
+ }
StringWriter sw = new StringWriter();
cause.printStackTrace( new PrintWriter( sw ) );
@@ -689,4 +693,3 @@
response.getOutputStream().print( html.toString() );
}
}
-
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>