01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.aspectwerkz.exception;
05:
06: import java.io.PrintStream;
07: import java.io.PrintWriter;
08:
09: /**
10: * Thrown when error in definition.
11: *
12: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
13: */
14: public class DefinitionException extends RuntimeException {
15: /**
16: * Original exception which caused this exception.
17: */
18: private Throwable originalException;
19:
20: /**
21: * Sets the message for the exception.
22: *
23: * @param message the message
24: */
25: public DefinitionException(final String message) {
26: super (message);
27: }
28:
29: /**
30: * Sets the message for the exception and the original exception being wrapped.
31: *
32: * @param message the detail of the error message
33: * @param throwable the original exception
34: */
35: public DefinitionException(String message, Throwable throwable) {
36: super (message);
37: this .originalException = throwable;
38: }
39:
40: /**
41: * Print the full stack trace, including the original exception.
42: */
43: public void printStackTrace() {
44: printStackTrace(System.err);
45: }
46:
47: /**
48: * Print the full stack trace, including the original exception.
49: *
50: * @param ps the byte stream in which to print the stack trace
51: */
52: public void printStackTrace(PrintStream ps) {
53: super .printStackTrace(ps);
54: if (this .originalException != null) {
55: this .originalException.printStackTrace(ps);
56: }
57: }
58:
59: /**
60: * Print the full stack trace, including the original exception.
61: *
62: * @param pw the character stream in which to print the stack trace
63: */
64: public void printStackTrace(PrintWriter pw) {
65: super.printStackTrace(pw);
66: if (this.originalException != null) {
67: this.originalException.printStackTrace(pw);
68: }
69: }
70: }
|