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