You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jo...@apache.org on 2001/10/13 21:58:32 UTC

cvs commit: jakarta-turbine-3/src/java/org/apache/turbine Turbine.java

jon         01/10/13 12:58:32

  Modified:    src/java/org/apache/turbine Turbine.java
  Log:
  let me prefix this by: jason is going to hate this change and i am
  going to argue for it until there is a better solution... :-)
  
  what it does is allow us to define an Error.vm template and still get
  stack traces and such in the nice rendered page instead of just going into
  oblivion with an ugly stack trace posted to the output...
  
  i also check to make sure that data.getOut() != null before trying to
  close it, just to be safe
  
  i also put the reallyscrewednow stack trace into <pre> tags so that it can
  be read a bit easier
  
  Revision  Changes    Path
  1.10      +34 -9     jakarta-turbine-3/src/java/org/apache/turbine/Turbine.java
  
  Index: Turbine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/Turbine.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Turbine.java	2001/09/21 03:21:00	1.9
  +++ Turbine.java	2001/10/13 19:58:32	1.10
  @@ -111,7 +111,7 @@
    * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
    * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
    * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
  - * @version $Id: Turbine.java,v 1.9 2001/09/21 03:21:00 jvanzyl Exp $
  + * @version $Id: Turbine.java,v 1.10 2001/10/13 19:58:32 jon Exp $
    */
   public class Turbine
       extends HttpServlet
  @@ -262,11 +262,32 @@
               // is listed below here could eventually be anything :-)
               if (pipeline.process(data))
               {
  -                pipeline.preExecuteAction(data);
  -                pipeline.executeAction(data);
  -                pipeline.postExecuteAction(data);
  -                pipeline.execute(data);
  -                pipeline.finished(data);
  +                try
  +                {
  +                    pipeline.preExecuteAction(data);
  +                    pipeline.executeAction(data);
  +                    pipeline.postExecuteAction(data);
  +                }
  +                catch (Exception e)
  +                {
  +                    data.setTarget(configuration
  +                        .getString("template.error","/Error.vm"));
  +                    data.setStackTrace(StringUtils.stackTrace(e),e);
  +                }
  +                try
  +                {
  +                    pipeline.execute(data);
  +                    pipeline.finished(data);
  +                }
  +                catch (Exception f)
  +                {
  +                    // try again with a different target
  +                    data.setTarget(configuration
  +                        .getString("template.error","/Error.vm"));
  +                    data.setStackTrace(StringUtils.stackTrace(f),f);
  +                    pipeline.execute(data);
  +                    pipeline.finished(data);
  +                }
   
                   /*
                   TODO: Move this logic into the pipeline.
  @@ -295,7 +316,10 @@
               // Make sure to close the outputstream when we are done.
               try
               {
  -                data.getOut().close();
  +                if (data.getOut() != null)
  +                {
  +                    data.getOut().close();
  +                }
               }
               catch (Exception ignored)
               {
  @@ -360,10 +384,11 @@
               // This should be more useful and formatted in
               // a useful fashion but this will get rid of ECS
               // for the time being.
  -            data.setStackTrace(StringUtils.stackTrace(t),t);
  +            String trace = StringUtils.stackTrace(t);
  +            data.setStackTrace(trace,t);
               data.getResponse().setContentType(data.getContentType());
               data.getResponse().setStatus(data.getStatusCode());
  -            data.getOut().print(StringUtils.stackTrace(t));
  +            data.getOut().print("<pre>\n" + trace + "\n</pre>");
           }
           // Catch this one because it occurs if some code hasn't been
           // completely re-compiled after a change..
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org