KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > teamkonzept > lib > TKException


1 package com.teamkonzept.lib;
2
3 import java.io.*;
4
5 /**
6     this is the wrapper class for all Exceptions
7  * @author $Author: alexandergrosse $
8  * @version $Revision: 1.7.6.1 $
9 */

10 public class TKException
11     extends Exception JavaDoc
12     implements ErrorCodes
13 {
14     private int errorCode;
15     private Throwable JavaDoc originalException;
16
17     /** exception public to the user ? */
18     private boolean isPublic;
19
20     private int severity;
21
22     /** Values for the error templates */
23     private TKHashtable params = null;
24
25     // Optional arguments for message formatting.
26
private Object JavaDoc[] arguments = null;
27
28     /**
29         constructor, if the error was detected without a thrown exception,
30         e.g. by testing some values
31     */

32     public TKException (String JavaDoc description,
33                         int _errorCode,
34                         int _severity,
35                         boolean _ispublic,
36                         Throwable JavaDoc t)
37     {
38         this(description, _errorCode, _severity, _ispublic, null, t);
39     }
40
41     public TKException (String JavaDoc description,
42                         int _errorCode,
43                         int _severity,
44                         boolean _ispublic,
45                         Object JavaDoc[] arguments,
46                         Throwable JavaDoc t)
47     {
48         super(description);
49         errorCode = _errorCode;
50         originalException = t;
51         severity = _severity;
52         isPublic = _ispublic;
53         this.arguments = arguments;
54     }
55
56     public void setParams(TKHashtable _hash)
57     {
58         params = _hash;
59     }
60
61     public Throwable JavaDoc getOriginalException()
62     {
63         return originalException;
64     }
65
66     public int getErrorCode()
67     {
68         return errorCode;
69     }
70
71     public boolean isPublic()
72     {
73         return isPublic;
74     }
75
76     public int getSeverity()
77     {
78         return severity;
79     }
80
81     public Object JavaDoc[] getArguments ()
82     {
83         return arguments;
84     }
85
86     /**
87         Convenience
88     */

89     public String JavaDoc getFullStackTrace()
90     {
91         if (originalException == null)
92             return "";
93         StringWriter strWriter = new StringWriter();
94         PrintWriter pw = new PrintWriter(strWriter);
95         originalException.printStackTrace(pw);
96         pw.close();
97         return strWriter.getBuffer().toString();
98     }
99 }
100
Popular Tags