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