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

  Modified:    src/de/infor/ce/http HttpException.java
  Log:
  exception redesign. Improved null-pointer treatment. coherent environment and 
logging facilities.
  LGPL references.
  
  Revision  Changes    Path
  1.5       +56 -49    zoap/src/de/infor/ce/http/HttpException.java
  
  Index: HttpException.java
  ===================================================================
  RCS file: /products/cvs/ejboss/zoap/src/de/infor/ce/http/HttpException.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- HttpException.java        2000/12/22 15:43:23     1.4
  +++ HttpException.java        2001/01/04 14:45:04     1.5
  @@ -25,69 +25,76 @@
    * The most general exception thrown in this http-server package. Something must 
have been wrong. Catch
    * this if you are an ignorant or just lazy.
    * @author jung
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    */
   
   public class HttpException extends Exception {
   
  -     /** an embedded exception */
  -     Throwable actualThrowable;
  +     /** nested exception */
  +     protected Throwable detail;
   
  -     /** default constructor */
  +     /** constructs a barebone <code>ConsoleException</code> */
  +     public HttpException() { }
   
  -     public HttpException() {
  +     /** Constructs a <code>ConsoleException</code> with the specified error 
message. */
  +     public HttpException(String s) {
  +             super(s);
        }
   
  -    /*
  -     * message-based constructor
  -     */
  -
  -     public HttpException(String message) {
  -             super(message);
  -     }
  -
  -     /** message-based constructor for embedding an arbitrary throwable */
  -
  -     public HttpException(String message, Throwable throwable) {
  -             super(message);
  -             actualThrowable = throwable;
  +     /** constructs a <code>ConsoleException</code> with the specified detail 
message and a nested throwable. */
  +     public HttpException(String s, Throwable ex) {
  +             super(s);
  +             detail = ex;
        }
   
  -     /** constructor for embedding an arbitrary throwable */
  -
  -     public HttpException(Throwable throwable) {
  +     /** constructs a <code>ConsoleException</code> with a nested throwable. */
  +     public HttpException(Throwable ex) {
                super();
  -             actualThrowable = throwable;
  +             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);
  +                     }
  +             }
        }
  -
  -     /** accesses the embedded throwable */
  -
  -     public Throwable getActualThrowable() {
  -             return actualThrowable;
  -     }
  -
  -     /** accesses the embedded throwable */
  -
  -     public void setActualThrowable(Throwable throwable) {
  -             actualThrowable = throwable;
  -     }
  -
  -     /** the printStackTrace method produces recursive traces */
  -     public void printStackTrace() {
  -             super.printStackTrace();
  -             if (actualThrowable != null)
  -                     actualThrowable.printStackTrace();
  -     }
  -
   
   } // HttpException
   
  
  
  

Reply via email to