commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: jakarta-commons/latka/src/java/org/apache/commons/latka LatkaException.java
Date Fri, 01 Feb 2002 06:38:51 GMT
dion        02/01/31 22:38:51

  Modified:    latka/src/java/org/apache/commons/latka LatkaException.java
  Log:
  Added printStackTrace's
  
  Revision  Changes    Path
  1.6       +98 -52    jakarta-commons/latka/src/java/org/apache/commons/latka/LatkaException.java
  
  Index: LatkaException.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/LatkaException.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- LatkaException.java	4 Sep 2001 05:37:13 -0000	1.5
  +++ LatkaException.java	1 Feb 2002 06:38:51 -0000	1.6
  @@ -59,6 +59,9 @@
   
   package org.apache.commons.latka;
   
  +import java.io.PrintStream;
  +import java.io.PrintWriter;
  +
   import org.xml.sax.SAXException;
   
   /**
  @@ -67,63 +70,106 @@
    * (validation errors, SAX problems, etc.)
    *
    * @author Morgan Delagrange
  + * @author dIon Gillard
  + * @version $Id: LatkaException.java,v 1.6 2002/02/01 06:38:51 dion Exp $
    */
   public class LatkaException extends Exception {
     
  -  protected Exception _wrappedException = null;
  +    /**
  +     * The original exception
  +     */
  +    protected Exception _wrappedException = null;
  +
  +    /**
  +     * Standard exception constructor
  +     * @param message some text explaining the exception
  +     */
  +    public LatkaException(String message) {
  +        super(message);
  +    }
   
  -  /**
  -   * Standard exception
  -   */
  -  public LatkaException(String message) {
  -    super(message);
  -  }
  -
  -  /**
  -   * Wrapped exception.
  -   *
  -   * @param e exception to wrap
  -   */
  -  public LatkaException(Exception e) {
  -    super(e.toString());
  -    _wrappedException = e;
  -  }
  -
  -  /**
  -   * Get a wrapped exception
  -   *
  -   * @return a wrapped exception, or null if no wrapped
  -   *         exception exists.
  -   */
  -  public Exception getException() {
  -    return _wrappedException;
  -  }
  -
  -  /**
  -   * Print a wrapped exception to stdout and, in the case
  -   * of SAXExceptions, an additional wrapped exception.
  -   * This method does _not_ print the exception's message
  -   * itself.
  -   *
  -   * @param e LatkaException with wrapped messages.
  -   */
  -  public static void printWrappedExceptions(LatkaException e) {
  -    Exception wrappedException = e.getException();
  -
  -    if (wrappedException != null) {
  -      System.out.println("Wraps exception:");
  -      e.printStackTrace();
  -
  -      if (wrappedException instanceof SAXException) {
  -        Exception saxWrappedException =
  -          ((SAXException) wrappedException).getException();
  -        if (saxWrappedException != null) {
  -          System.out.println("Wraps exception:");
  -          e.printStackTrace();
  -        }
  -      }
  +    /**
  +     * Wrapped exception.
  +     *
  +     * @param e exception to wrap
  +     */
  +    public LatkaException(Exception e) {
  +        super(e.toString());
  +        _wrappedException = e;
  +    }
  +
  +    /**
  +     * Get a wrapped exception
  +     *
  +     * @return a wrapped exception, or null if no wrapped
  +     *         exception exists.
  +     */
  +    public Exception getException() {
  +        return _wrappedException;
  +    }
  +
  +    /**
  +     * Print a wrapped exception to stdout and, in the case
  +     * of SAXExceptions, an additional wrapped exception.
  +     * This method does _not_ print the exception's message
  +     * itself.
  +     *
  +     * @param e LatkaException with wrapped messages.
  +     */
  +    public static void printWrappedExceptions(LatkaException e) {
  +        Exception wrappedException = e.getException();
  +
  +        if (wrappedException != null) {
  +            System.out.println("Wraps exception:");
  +            e.printStackTrace();
  +
  +            if (wrappedException instanceof SAXException) {
  +                Exception saxWrappedException =
  +                  ((SAXException) wrappedException).getException();
  +                if (saxWrappedException != null) {
  +                    System.out.println("Wraps exception:");
  +                    e.printStackTrace();
  +                }
  +            }
   
  +        }
       }
  -  }
   
  +    /**
  +     * provide wrapped exception details 
  +     */
  +    public void printStackTrace() {
  +        if (getException() != null) {
  +            System.err.println("Wrapped Exception details:");
  +            getException().printStackTrace();
  +        }
  +        
  +        super.printStackTrace();
  +    }
  +    
  +    /**
  +     * provide wrapped exception details 
  +     * @param s PrintStream to print to
  +     */
  +    public void printStackTrace(PrintStream s) {
  +        if (getException() != null) {
  +            s.println("Wrapped Exception details:");
  +            getException().printStackTrace(s);
  +        }
  +        
  +        super.printStackTrace(s);
  +    }
  +    
  +    /**
  +     * 
  +     */
  +    public void printStackTrace(PrintWriter s) {
  +        if (getException() != null) {
  +            s.println("Wrapped Exception details:");
  +            getException().printStackTrace(s);
  +        }
  +        
  +        super.printStackTrace(s);
  +    }
  +    
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message