You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by ni...@apache.org on 2002/03/18 13:22:53 UTC

cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/notification DefaultNotifyingBuilder.java

nicolaken    02/03/18 04:22:53

  Modified:    src/java/org/apache/cocoon/components/notification
                        DefaultNotifyingBuilder.java
  Log:
  Added code by Marc Liyanage, originally in FriendlyTransformerException.java.
  Still needs some changes in the error notification system to make it works at its full.
  
  Revision  Changes    Path
  1.6       +33 -6     xml-cocoon2/src/java/org/apache/cocoon/components/notification/DefaultNotifyingBuilder.java
  
  Index: DefaultNotifyingBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/notification/DefaultNotifyingBuilder.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultNotifyingBuilder.java	22 Feb 2002 07:00:10 -0000	1.5
  +++ DefaultNotifyingBuilder.java	18 Mar 2002 12:22:53 -0000	1.6
  @@ -54,16 +54,22 @@
   import org.apache.avalon.framework.component.Component;
   
   import org.xml.sax.SAXException;
  +import org.xml.sax.SAXParseException;
  +
  +import javax.xml.transform.TransformerException;
  +import javax.xml.transform.SourceLocator;
   
   import java.io.PrintWriter;
   import java.io.StringWriter;
  +
   import java.util.Map;
   
   /**
    *  Generates an Notifying representation of widely used objects.
    *
  - * @author <a href="mailto:barozzi@nicolaken.com">Nicola Ken Barozzi</a>
  - * @version CVS $Id: DefaultNotifyingBuilder.java,v 1.5 2002/02/22 07:00:10 cziegeler Exp $
  + * @author <a href="mailto:nicolaken@apache.org">Nicola Ken Barozzi</a>
  + * @author Marc Liyanage (futureLAB AG)
  + * @version CVS $Id: DefaultNotifyingBuilder.java,v 1.6 2002/03/18 12:22:53 nicolaken Exp $
    * @created 24 August 2000
    */
   public class DefaultNotifyingBuilder implements NotifyingBuilder, Component {
  @@ -84,13 +90,34 @@
         n.setType("error");
         n.setTitle("An error occurred");
         if (t != null) {
  +      
           n.setSource(t.getClass().getName());
  -        n.setMessage(t.getMessage());
  -        n.setDescription(t.toString());
   
  -        Throwable rootT = getRootCause(t);
  -        n.addExtraDescription("original message", rootT.toString());
  +        Throwable rootCauseThrowable = getRootCause(t);
  +        n.addExtraDescription("original message", rootCauseThrowable.toString());
   
  +        if (rootCauseThrowable instanceof SAXParseException) {
  +        
  +            SAXParseException saxParseException = (SAXParseException) rootCauseThrowable;           
  +            n.setMessage         (                           saxParseException.getMessage()      );
  +            n.addExtraDescription("location",                saxParseException.getSystemId()     );
  +            n.addExtraDescription("line"    , String.valueOf(saxParseException.getLineNumber())  );
  +            n.addExtraDescription("column"  , String.valueOf(saxParseException.getColumnNumber()));
  +        } 
  +        else if (rootCauseThrowable instanceof TransformerException) {
  +            TransformerException transformerException = (TransformerException) rootCauseThrowable;
  +            SourceLocator sourceLocator = transformerException.getLocator();
  +            n.setMessage         (                           transformerException.getMessage());
  +            n.addExtraDescription("location",                sourceLocator.getSystemId()      );
  +            n.addExtraDescription("line"    , String.valueOf(sourceLocator.getLineNumber())   );
  +            n.addExtraDescription("column"  , String.valueOf(sourceLocator.getColumnNumber()) );
  +        }
  +        else{
  +                n.setMessage(t.getMessage());
  +         }
  +        
  +        n.setDescription(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
  
  
  

----------------------------------------------------------------------
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