KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > pmd > PMDException


1 /**
2  * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3  */

4 package net.sourceforge.pmd;
5
6 import java.io.PrintStream JavaDoc;
7 import java.io.PrintWriter JavaDoc;
8
9 /**
10  * A convenience exception wrapper. Contains the original exception, if any. Also, contains
11  * a severity number (int). Zero implies no severity. The higher the number the greater the
12  * severity.
13  *
14  * @author Donald A. Leckie
15  * @version $Revision: 1.6 $, $Date: 2006/02/10 14:15:23 $
16  * @since August 30, 2002
17  */

18 public class PMDException extends Exception JavaDoc {
19
20     private Exception JavaDoc reason;
21     private int severity;
22
23     public PMDException(String JavaDoc message) {
24         super(message);
25     }
26
27     public PMDException(String JavaDoc message, Exception JavaDoc reason) {
28         super(message);
29         this.reason = reason;
30     }
31
32     public void printStackTrace() {
33         printStackTrace(System.err);
34     }
35
36     public void printStackTrace(PrintStream JavaDoc s) {
37         super.printStackTrace(s);
38         if (this.reason != null) {
39             s.print("Caused by: ");
40             this.reason.printStackTrace(s);
41         }
42     }
43
44     public void printStackTrace(PrintWriter JavaDoc s) {
45         super.printStackTrace(s);
46         if (this.reason != null) {
47             s.print("Caused by: ");
48             this.reason.printStackTrace(s);
49         }
50     }
51
52     public Exception JavaDoc getReason() {
53         return reason;
54     }
55
56     public void setSeverity(int severity) {
57         this.severity = severity;
58     }
59
60     public int getSeverity() {
61         return severity;
62     }
63 }
Popular Tags