View Javadoc

    1   /***************************************************************************************
    2    * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved.                 *
    3    * http://aspectwerkz.codehaus.org                                                    *
    4    * ---------------------------------------------------------------------------------- *
    5    * The software in this package is published under the terms of the LGPL license      *
    6    * a copy of which has been included with this distribution in the license.txt file.  *
    7    **************************************************************************************/
    8   package org.codehaus.aspectwerkz.exception;
    9
    10  import java.io.PrintStream;
    11  import java.io.PrintWriter;
    12
    13  /***
    14   * Thrown when error in definition.
    15   *
    16   * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
    17   * @author <a href="mailto:vmassol@apache.org">Vincent Massol </a>
    18   */
    19  public class DefinitionException extends RuntimeException {
    20      /***
    21       * Original exception which caused this exception.
    22       */
    23      private Throwable originalException;
    24
    25      /***
    26       * Sets the message for the exception.
    27       *
    28       * @param message the message
    29       */
    30      public DefinitionException(final String message) {
    31          super(message);
    32      }
    33
    34      /***
    35       * Sets the message for the exception and the original exception being wrapped.
    36       *
    37       * @param message   the detail of the error message
    38       * @param throwable the original exception
    39       */
    40      public DefinitionException(String message, Throwable throwable) {
    41          super(message);
    42          this.originalException = throwable;
    43      }
    44
    45      /***
    46       * Print the full stack trace, including the original exception.
    47       */
    48      public void printStackTrace() {
    49          printStackTrace(System.err);
    50      }
    51
    52      /***
    53       * Print the full stack trace, including the original exception.
    54       *
    55       * @param ps the byte stream in which to print the stack trace
    56       */
    57      public void printStackTrace(PrintStream ps) {
    58          super.printStackTrace(ps);
    59          if (this.originalException != null) {
    60              this.originalException.printStackTrace(ps);
    61          }
    62      }
    63
    64      /***
    65       * Print the full stack trace, including the original exception.
    66       *
    67       * @param pw the character stream in which to print the stack trace
    68       */
    69      public void printStackTrace(PrintWriter pw) {
    70          super.printStackTrace(pw);
    71          if (this.originalException != null) {
    72              this.originalException.printStackTrace(pw);
    73          }
    74      }
    75  }