01: package org.acm.seguin.pmd;
02:
03: import java.io.PrintStream;
04: import java.io.PrintWriter;
05:
06: /**
07: * A convenience exception wrapper. Contains the original exception, if any. Also, contains
08: * a severity number (int). Zero implies no severity. The higher the number the greater the
09: * severity.
10: *
11: * @author Donald A. Leckie
12: * @since August 30, 2002
13: * @version $Revision: 1.1 $, $Date: 2003/07/29 20:51:58 $
14: */
15: public class PMDException extends Exception {
16:
17: private Exception reason;
18: private int severity;
19:
20: public PMDException(String message) {
21: super (message);
22: }
23:
24: public PMDException(String message, Exception reason) {
25: super (message);
26: this .reason = reason;
27: }
28:
29: public void printStackTrace() {
30: printStackTrace(System.err);
31: }
32:
33: public void printStackTrace(PrintStream s) {
34: super .printStackTrace(s);
35: if (this .reason != null) {
36: s.print("Caused by: ");
37: this .reason.printStackTrace(s);
38: }
39: }
40:
41: public void printStackTrace(PrintWriter s) {
42: super .printStackTrace(s);
43: if (this .reason != null) {
44: s.print("Caused by: ");
45: this .reason.printStackTrace(s);
46: }
47: }
48:
49: public Exception getReason() {
50: return reason;
51: }
52:
53: public void setSeverity(int severity) {
54: this .severity = severity;
55: }
56:
57: public int getSeverity() {
58: return severity;
59: }
60: }
|