KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > aspectwerkz > exception > DefinitionException


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.aspectwerkz.exception;
5
6 import java.io.PrintStream JavaDoc;
7 import java.io.PrintWriter JavaDoc;
8
9 /**
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 JavaDoc {
15   /**
16    * Original exception which caused this exception.
17    */

18   private Throwable JavaDoc originalException;
19
20   /**
21    * Sets the message for the exception.
22    *
23    * @param message the message
24    */

25   public DefinitionException(final String JavaDoc 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 JavaDoc message, Throwable JavaDoc 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 JavaDoc 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 JavaDoc pw) {
65     super.printStackTrace(pw);
66     if (this.originalException != null) {
67       this.originalException.printStackTrace(pw);
68     }
69   }
70 }
Popular Tags