1 /**
2 * AUTOHIT 2003
3 * Copyright Erich P Gatejen (c) 1989,1997,2003,2004
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Additional license information can be found in the documentation.
19 * @author Erich P Gatejen
20 */
21 package autohit.common;
22
23 /**
24 * A base exception for Autohit. The specific error is given in the numeric
25 * field. All default exceptions are assumed to be ERRORS.
26 *
27 * @author Erich P. Gatejen
28 * @version 1.0
29 * <i>Version History</i>
30 * <code>EPG - Initial - 14May03<br>
31 * EPG - Added chaining support - 11Jun03<br>
32 * EPG - Chenge to new error code scheme - 19Jul03</code>
33 *
34 */
35 public class AutohitException extends Exception implements AutohitErrorCodes {
36
37 final static long serialVersionUID = 1;
38
39 /**
40 * Exception numeric
41 */
42 public int numeric;
43
44 /**
45 * Numeric values for the exception.
46 */
47 public static final int AUTOHIT_EXCEPTION_GENERIC = CODE_DEFAULT_ERROR;
48
49 /**
50 * Default Constructor.
51 */
52 public AutohitException() {
53 super("Messageless AutohitException");
54 numeric = AUTOHIT_EXCEPTION_GENERIC;
55 }
56
57 /**
58 * Default Constructor with Cause
59 * @param theCause for exception chaining
60 */
61 public AutohitException(Throwable theCause) {
62 super("Messageless AutohitException", theCause);
63 numeric = AUTOHIT_EXCEPTION_GENERIC;
64 }
65
66 /**
67 * Message constructor
68 * @param message text message for exception
69 */
70 public AutohitException(String message) {
71 super(message);
72 numeric = AUTOHIT_EXCEPTION_GENERIC;
73 }
74
75 /**
76 * Message constructor with Cause
77 * @param message text message for exception
78 * @param theCause for exception chaining
79 */
80 public AutohitException(String message, Throwable theCause) {
81 super(message, theCause);
82 numeric = AUTOHIT_EXCEPTION_GENERIC;
83 }
84
85 /**
86 * Message constructor
87 * @param n numeric error
88 */
89 public AutohitException(int n) {
90 super("Numbered AutohitException =" + n);
91 numeric = n;
92 }
93
94 /**
95 * Message constructor with cause
96 * @param n numeric error
97 * @param theCause for exception chaining
98 */
99 public AutohitException(int n, Throwable theCause) {
100 super("Numbered AutohitException =" + n, theCause);
101 numeric = n;
102 }
103
104 /**
105 * Message constructor
106 * @param message text message for exception
107 * @param n numeric error
108 */
109 public AutohitException(String message, int n) {
110 super(message);
111 numeric = n;
112 }
113
114 /**
115 * Message constructor with cause
116 * @param message text message for exception
117 * @param n numeric error
118 * @param theCause for exception chaining
119 */
120 public AutohitException(String message, int n, Throwable theCause) {
121 super(message, theCause);
122 numeric = n;
123 }
124
125 /**
126 * Helper for determining level - Informational
127 * @param code numeric code
128 * @return true if it is informational
129 */
130 static public boolean isInformational(int code) {
131 if ((code >= FLOOR_NUMERIC) && (code < CODE_DEFAULT_WARNING))
132 return true;
133 else
134 return false;
135 }
136
137 /**
138 * Helper for determining level - Warning
139 * @param code numeric code
140 * @return true if it is a warning
141 */
142 static public boolean isWarning(int code) {
143 if ((code >= CODE_DEFAULT_WARNING) && (code < CODE_DEFAULT_ERROR))
144 return true;
145 else
146 return false;
147 }
148
149 /**
150 * Helper for determining level - Error
151 * @param code numeric code
152 * @return true if it is an error
153 */
154 static public boolean isError(int code) {
155 if ((code >= CODE_DEFAULT_ERROR) && (code < CODE_DEFAULT_FAULT))
156 return true;
157 else
158 return false;
159 }
160
161 /**
162 * Helper for determining level - Fault
163 * @param code numeric code
164 * @return true if it is a fault
165 */
166 static public boolean isFault(int code) {
167 if ((code >= CODE_DEFAULT_FAULT) && (code < CODE_DEFAULT_PANIC))
168 return true;
169 else
170 return false;
171 }
172
173 /**
174 * Helper for determining level - Panic
175 * @param code numeric code
176 * @return true if it is a panic
177 */
178 static public boolean isPanic(int code) {
179 if ((code >= CODE_DEFAULT_PANIC) && (code < TOP_NUMERIC))
180 return true;
181 else
182 return false;
183 }
184 }
|