01: package com.teamkonzept.lib;
02:
03: import java.io.*;
04:
05: /**
06: this is the wrapper class for all Exceptions
07: * @author $Author: alexandergrosse $
08: * @version $Revision: 1.7.6.1 $
09: */
10: public class TKException extends Exception implements ErrorCodes {
11: private int errorCode;
12: private Throwable originalException;
13:
14: /** exception public to the user ? */
15: private boolean isPublic;
16:
17: private int severity;
18:
19: /** Values for the error templates */
20: private TKHashtable params = null;
21:
22: // Optional arguments for message formatting.
23: private Object[] arguments = null;
24:
25: /**
26: constructor, if the error was detected without a thrown exception,
27: e.g. by testing some values
28: */
29: public TKException(String description, int _errorCode,
30: int _severity, boolean _ispublic, Throwable t) {
31: this (description, _errorCode, _severity, _ispublic, null, t);
32: }
33:
34: public TKException(String description, int _errorCode,
35: int _severity, boolean _ispublic, Object[] arguments,
36: Throwable t) {
37: super (description);
38: errorCode = _errorCode;
39: originalException = t;
40: severity = _severity;
41: isPublic = _ispublic;
42: this .arguments = arguments;
43: }
44:
45: public void setParams(TKHashtable _hash) {
46: params = _hash;
47: }
48:
49: public Throwable getOriginalException() {
50: return originalException;
51: }
52:
53: public int getErrorCode() {
54: return errorCode;
55: }
56:
57: public boolean isPublic() {
58: return isPublic;
59: }
60:
61: public int getSeverity() {
62: return severity;
63: }
64:
65: public Object[] getArguments() {
66: return arguments;
67: }
68:
69: /**
70: Convenience
71: */
72: public String getFullStackTrace() {
73: if (originalException == null)
74: return "";
75: StringWriter strWriter = new StringWriter();
76: PrintWriter pw = new PrintWriter(strWriter);
77: originalException.printStackTrace(pw);
78: pw.close();
79: return strWriter.getBuffer().toString();
80: }
81: }
|