User: jung    
  Date: 01/01/04 06:45:08

  Modified:    src/org/zoap/xml XmlException.java
  Log:
  exception redesign. Improved null-pointer treatment. coherent environment and 
logging facilities.
  LGPL references.
  
  Revision  Changes    Path
  1.4       +58 -41    zoap/src/org/zoap/xml/XmlException.java
  
  Index: XmlException.java
  ===================================================================
  RCS file: /products/cvs/ejboss/zoap/src/org/zoap/xml/XmlException.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XmlException.java 2001/01/03 10:23:49     1.3
  +++ XmlException.java 2001/01/04 14:45:08     1.4
  @@ -26,58 +26,75 @@
   /**
    * XmlException is an IOException since we deal with serialisation in this package.
    * @author jung
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   
   public class XmlException extends IOException {
   
  -     /** an embedded exception */
  -     Throwable actualThrowable;
  +     /** nested exception */
  +     protected Throwable detail;
   
  -     /** constructor for embedding an arbitrary throwable */
  -     public XmlException(Throwable throwable) {
  -             super();
  -             actualThrowable = throwable;
  -     }
  +     /** constructs a barebone <code>ConsoleException</code> */
  +     public XmlException() { }
   
  -     /** message-based constructor for embedding an arbitrary throwable */
  -     public XmlException(String message, Throwable throwable) {
  -             super(message);
  -             actualThrowable = throwable;
  +     /** Constructs a <code>ConsoleException</code> with the specified error 
message. */
  +     public XmlException(String s) {
  +             super(s);
        }
   
  -    /** usual message-based constructor */
  -     public XmlException(String message) {
  -             super(message);
  +     /** constructs a <code>ConsoleException</code> with the specified detail 
message and a nested throwable. */
  +     public XmlException(String s, Throwable ex) {
  +             super(s);
  +             detail = ex;
        }
   
  -     /** default constructor */
  -     public XmlException() {
  -     }
  -
  -     /** accesses the embedded throwable */
  -     public Throwable getActualThrowable() {
  -             return actualThrowable;
  -     }
  -
  -     /** the printStackTrace method produces recursive traces */
  -     public void printStackTrace() {
  -             super.printStackTrace();
  -             if (actualThrowable != null)
  -                     actualThrowable.printStackTrace();
  -     }
  -
  -     /** accesses the embedded throwable */
  -     public void setActualThrowable(Throwable throwable) {
  -             actualThrowable = throwable;
  +     /** constructs a <code>ConsoleException</code> with a nested throwable. */
  +     public XmlException(Throwable ex) {
  +             super();
  +             detail = ex;
        }
   
  -     /** manipulate the toString method to also show the embedded throwable */
  -     public String toString() {
  -             if (actualThrowable != null) {
  -                     return super.toString() + ": embedded exception " + 
actualThrowable.toString();
  -             } else
  -                     return super.toString();
  +     /** returns the detail exception */
  +     public Throwable getDetail() {
  +             return detail;
  +     }
  +
  +     /** returns the detail message, including the message from the nested 
exception if there is one. */
  +     public String getMessage() {
  +             if (detail == null)
  +                     return super.getMessage();
  +             else
  +                     return super.getMessage() +
  +                     "; nested exception is: \n\t" +
  +                     detail.toString();
  +     }
  +
  +     /**
  +      * prints the composite message and the embedded stack trace to the specified 
stream <code>ps</code>.
  +      * @param ps the print stream
  +      */
  +     public void printStackTrace(java.io.PrintStream ps) {
  +             synchronized(ps) {
  +                     super.printStackTrace(ps);
  +                     if (detail != null) {
  +                             ps.println("\t nested exception trace is:");
  +                             detail.printStackTrace(ps);
  +                     }
  +             }
  +     }
  +
  +     /**
  +      * Prints the composite message and the embedded stack trace to the specified 
print writer <code>pw</code>.
  +      * @param pw the print writer
  +      */
  +     public void printStackTrace(java.io.PrintWriter pw) {
  +             synchronized(pw) {
  +                     super.printStackTrace(pw);
  +                     if (detail != null) {
  +                             pw.println("\t nested exception trace is:");
  +                             detail.printStackTrace(pw);
  +                     }
  +             }
        }
   }
   
  
  
  

Reply via email to