axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis ConfigurationException.java
Date Fri, 03 Jan 2003 07:38:12 GMT
stevel      2003/01/02 23:38:12

  Modified:    java/src/org/apache/axis ConfigurationException.java
  Log:
  Retain the underlying exception *and* keep the stack trace slightly separate from the base
message, with an overridden toString() method to bring the stack out with the message.
  
  Reason: lets AxisFaults be pulled out at a higher level, and allows the caller to bypass
the stack info, even if it is carried around server-side.
  
  Revision  Changes    Path
  1.12      +53 -14    xml-axis/java/src/org/apache/axis/ConfigurationException.java
  
  Index: ConfigurationException.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/ConfigurationException.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ConfigurationException.java	11 Dec 2002 22:38:06 -0000	1.11
  +++ ConfigurationException.java	3 Jan 2003 07:38:12 -0000	1.12
  @@ -70,7 +70,14 @@
   public class ConfigurationException extends IOException {
   
       /**
  -     * Copy the orginal execption by default
  +     * any contained exception
  +     */
  +    private Exception containedException=null;
  +
  +    private String stackTrace="";
  +
  +    /**
  +     * Copy the orginal exception by default
        */
       protected static boolean copyStackByDefault= true;
   
  @@ -83,21 +90,33 @@
        * @param message String form of the error
        */
       public ConfigurationException(String message) {
  -        this(new Exception(message));
  +        super(message);
  +        if(copyStackByDefault) {
  +            stackTrace= JavaUtils.stackToString(this);
  +        }
  +        logException( this);
       }
   
       /**
        * Construct a ConfigurationException from an Exception.
        * @param exception original exception which was unexpected
        */
  -    public ConfigurationException(Exception e) {
  -        super(e.toString()  + (copyStackByDefault? ("\n"
  -           + JavaUtils.stackToString(e)) : "" ));
  +    public ConfigurationException(Exception exception) {
  +        this(exception,copyStackByDefault);
  +    }
   
  -        // Log the exception the first time it appears.
  -        if (!(e instanceof ConfigurationException)) {
  -            log.debug("Exception: ", e);
  +    /**
  +     * stringify, including stack trace.
  +     * @return
  +     */
  +    public String toString() {
  +        String stack;
  +        if(stackTrace.length()== 0) {
  +            stack = "";
  +        } else {
  +            stack="\n"+stackTrace;
           }
  +        return super.toString()+stack;
       }
   
       /**
  @@ -105,13 +124,33 @@
        * @param exception original exception which was unexpected
        * @param copyStack set to true to copy the orginal exception's stack
        */
  -    public ConfigurationException(Exception e, final boolean copyStack) {
  -        super(e.toString()  + (copyStack ? "\n"
  -           + JavaUtils.stackToString(e) : "" ));
  -
  +    public ConfigurationException(Exception exception, final boolean copyStack) {
  +        super(exception.toString()  + (copyStack ? "\n"
  +           + JavaUtils.stackToString(exception) : "" ));
  +        containedException = exception;
  +        if(copyStack) {
  +            stackTrace = JavaUtils.stackToString(this);
  +        }
           // Log the exception the first time it appears.
  -        if (!(e instanceof ConfigurationException)) {
  -            log.debug("Exception: ", e);
  +        if (!(exception instanceof ConfigurationException)) {
  +            logException(exception);
           }
  +    }
  +
  +    /**
  +     * single point for logging exceptions.
  +     * @param exception
  +     */
  +    private void logException(Exception exception) {
  +        log.debug("Exception: ", exception);
  +    }
  +
  +    /**
  +     * get any contained exception
  +     * @return base exception or null
  +     * @since axis1.1
  +     */
  +    public Exception getContainedException() {
  +        return containedException;
       }
   }
  
  
  

Mime
View raw message