01: /*=============================================================================
02: * Copyright Texas Instruments 2000. All Rights Reserved.
03: *
04: * This program is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This program is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: *
18: * $ProjectHeader: OSCRIPT 0.155 Fri, 20 Dec 2002 18:34:22 -0800 rclark $
19: */
20:
21: package oscript.exceptions;
22:
23: /**
24: * A <code>ProgrammingErrorException</code> is thrown in cases that should
25: * only be reached due to a programming error, unimplemented code, etc.
26: *
27: * @author Rob Clark
28: * @version 0.1
29: */
30: public class ProgrammingErrorException extends RuntimeException {
31: private Throwable targetException;
32:
33: /*=======================================================================*/
34: /**
35: *
36: *
37: */
38: public ProgrammingErrorException(String msg) {
39: super ("programming error: " + msg);
40: }
41:
42: public ProgrammingErrorException(Throwable t) {
43: super ("this shouldn't happen: " + t);
44: targetException = t;
45: }
46:
47: public void printStackTrace() {
48: printStackTrace(System.err);
49: }
50:
51: public void printStackTrace(java.io.PrintStream ps) {
52: printStackTrace(new java.io.PrintWriter(
53: new java.io.OutputStreamWriter(ps)));
54: }
55:
56: public void printStackTrace(java.io.PrintWriter pw) {
57: if (targetException != null) {
58: pw.println("--- Target Exception: ------------------");
59: targetException.printStackTrace(pw);
60: pw.println("----------------------------------------");
61: }
62: super .printStackTrace(pw);
63: pw.flush();
64: }
65: }
66:
67: /*
68: * Local Variables:
69: * tab-width: 2
70: * indent-tabs-mode: nil
71: * mode: java
72: * c-indentation-style: java
73: * c-basic-offset: 2
74: * eval: (c-set-offset 'substatement-open '0)
75: * End:
76: */
|