You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2001/08/17 15:19:57 UTC

cvs commit: xml-cocoon2/src/org/apache/cocoon Notification.java

cziegeler    01/08/17 06:19:57

  Modified:    src/org/apache/cocoon Tag: cocoon_20_branch
                        Notification.java
  Log:
  Improved exception tracing
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.1   +26 -19    xml-cocoon2/src/org/apache/cocoon/Notification.java
  
  Index: Notification.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Notification.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- Notification.java	2001/05/31 17:37:32	1.2
  +++ Notification.java	2001/08/17 13:19:57	1.2.2.1
  @@ -11,7 +11,7 @@
   import java.io.PrintWriter;
   import java.io.StringWriter;
   import java.util.HashMap;
  -import org.apache.avalon.framework.CascadingException;
  +import org.apache.avalon.framework.CascadingThrowable;
   import org.xml.sax.SAXException;
   
   
  @@ -95,30 +95,37 @@
               setDescription(t.toString());
   
               extraDescriptions.put("exception", t.toString());
  +            // get the stacktrace: if the exception is a SAXException,
  +            // the stacktrace of the embedded exception is used as the
  +            // SAXException does not append it automatically
  +            Throwable stackTraceException;
  +            if (t instanceof SAXException
  +                && ((SAXException)t).getException() != null) {
  +                stackTraceException = ((SAXException)t).getException();
  +            } else {
  +                stackTraceException = t;
  +            }
               StringWriter stackTrace = new StringWriter();
  -            t.printStackTrace(new PrintWriter(stackTrace));
  +            stackTraceException.printStackTrace(new PrintWriter(stackTrace));
               extraDescriptions.put("stacktrace", stackTrace.toString());
   
  -            if(t instanceof CascadingException) {
  -                Throwable cause = ((CascadingException)t).getCause();
  -                if(cause != null) {
  -                    extraDescriptions.put("embedded exception", cause.toString());
  -                    stackTrace = new StringWriter();
  -                    cause.printStackTrace(new PrintWriter(stackTrace));
  -                    extraDescriptions.put("embedded exception stacktrace", stackTrace.toString());
  +            // if the throwable is a CascadingThrowable the strack trace
  +            // is automatically appended by the CascadingThrowable, so we
  +            // only have to deal with the case if the embedded exception
  +            // of the CascadingThrowable is a SAXException.
  +            if (t instanceof CascadingThrowable) {
  +                Throwable cause = ((CascadingThrowable)t).getCause();
  +                if(cause != null && cause instanceof SAXException) {
  +                    cause = ((SAXException)cause).getException();
  +                    if(cause != null) {
  +                        extraDescriptions.put("original exception", cause.toString());
  +                        stackTrace = new StringWriter();
  +                        cause.printStackTrace(new PrintWriter(stackTrace));
  +                        extraDescriptions.put("original exception stacktrace", stackTrace.toString());
  +                    }
                   }
               }
           }
  -    }
  -
  -    /**
  -     *  Constructor for the Notification object
  -     *
  -     *@param  t  Description of Parameter
  -     */
  -    public Notification(Object sender, SAXException se) {
  -        this(sender, (Throwable) se);
  -        addExtraDescription("SAX-processing-exception", se.getException().toString());
       }
   
       /**
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org