annotate dwt/DWTException.d @ 206:cca980503056

sync with dwt-linux, removed the simple.d
author Frank Benoit <benoit@tionex.de>
date Wed, 16 Apr 2008 20:36:50 +0200
parents dc7db4338dbe
children ab60f3309436
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
48
9a64a7781bab Added override and alias, first chunk. Thanks torhu for doing this patch.
Frank Benoit <benoit@tionex.de>
parents: 4
diff changeset
1 /*******************************************************************************
0
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
2 * Copyright (c) 2000, 2005 IBM Corporation and others.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
3 * All rights reserved. This program and the accompanying materials
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
4 * are made available under the terms of the Eclipse Public License v1.0
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
5 * which accompanies this distribution, and is available at
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
6 * http://www.eclipse.org/legal/epl-v10.html
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
7 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
8 * Contributors:
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
9 * IBM Corporation - initial API and implementation
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
10 * Port to the D programming language:
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
11 * Frank Benoit <benoit@tionex.de>
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
12 *******************************************************************************/
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
13 module dwt.DWTException;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
14
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
15 import dwt.DWT;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
16
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
17 import tango.core.Exception;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
18 import tango.io.Stdout;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
19
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
20 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
21 * This runtime exception is thrown whenever a recoverable error
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
22 * occurs internally in DWT. The message text and error code
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
23 * provide a further description of the problem. The exception
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
24 * has a <code>throwable</code> field which holds the underlying
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
25 * exception that caused the problem (if this information is
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
26 * available (i.e. it may be null)).
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
27 * <p>
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
28 * SWTExceptions are thrown when something fails internally,
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
29 * but DWT is left in a known stable state (eg. a widget call
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
30 * was made from a non-u/i thread, or there is failure while
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
31 * reading an Image because the source file was corrupt).
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
32 * </p>
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
33 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
34 * @see DWTError
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
35 */
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
36
57
41dbc4d9faab Update to tango trunk -r3152. Thanks DavidLeon for the adjustment of TracedException to Exception and creating the patch.
Frank Benoit <benoit@tionex.de>
parents: 48
diff changeset
37 public class DWTException : Exception {
0
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
38 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
39 * The DWT error code, one of DWT.ERROR_*.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
40 */
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
41 public int code;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
42
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
43 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
44 * The underlying throwable that caused the problem,
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
45 * or null if this information is not available.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
46 */
206
cca980503056 sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents: 59
diff changeset
47 public Exception throwable( Exception e ){
cca980503056 sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents: 59
diff changeset
48 this.next = e;
cca980503056 sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents: 59
diff changeset
49 return this.next;
cca980503056 sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents: 59
diff changeset
50 }
cca980503056 sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents: 59
diff changeset
51 public Exception throwable(){
cca980503056 sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents: 59
diff changeset
52 return this.next;
cca980503056 sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents: 59
diff changeset
53 }
cca980503056 sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents: 59
diff changeset
54
0
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
55
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
56 //static final long serialVersionUID = 3257282552304842547L;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
57
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
58 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
59 * Constructs a new instance of this class with its
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
60 * stack trace filled in. The error code is set to an
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
61 * unspecified value.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
62 */
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
63 public this () {
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
64 this (DWT.ERROR_UNSPECIFIED);
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
65 }
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
66
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
67 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
68 * Constructs a new instance of this class with its
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
69 * stack trace and message filled in. The error code is
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
70 * set to an unspecified value. Specifying <code>null</code>
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
71 * as the message is equivalent to specifying an empty string.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
72 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
73 * @param message the detail message for the exception
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
74 */
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
75 public this (char[] message) {
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
76 this (DWT.ERROR_UNSPECIFIED, message);
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
77 }
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
78
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
79 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
80 * Constructs a new instance of this class with its
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
81 * stack trace and error code filled in.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
82 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
83 * @param code the DWT error code
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
84 */
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
85 public this (int code) {
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
86 this (code, DWT.findErrorText (code));
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
87 }
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
88
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
89 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
90 * Constructs a new instance of this class with its
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
91 * stack trace, error code and message filled in.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
92 * Specifying <code>null</code> as the message is
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
93 * equivalent to specifying an empty string.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
94 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
95 * @param code the DWT error code
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
96 * @param message the detail message for the exception
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
97 */
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
98 public this (int code, char[] message) {
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
99 super (message);
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
100 this.code = code;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
101 }
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
102
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
103 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
104 * Returns the underlying throwable that caused the problem,
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
105 * or null if this information is not available.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
106 * <p>
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
107 * NOTE: This method overrides Throwable.getCause() that was
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
108 * added to JDK1.4. It is necessary to override this method
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
109 * in order for inherited printStackTrace() methods to work.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
110 * </p>
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
111 * @return the underlying throwable
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
112 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
113 * @since 3.1
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
114 */
57
41dbc4d9faab Update to tango trunk -r3152. Thanks DavidLeon for the adjustment of TracedException to Exception and creating the patch.
Frank Benoit <benoit@tionex.de>
parents: 48
diff changeset
115 public Exception getCause() {
0
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
116 return throwable;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
117 }
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
118
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
119 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
120 * Returns the string describing this DWTException object.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
121 * <p>
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
122 * It is combined with the message string of the Throwable
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
123 * which caused this DWTException (if this information is available).
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
124 * </p>
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
125 * @return the error message string of this DWTException object
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
126 */
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
127 public char[] getMessage () {
206
cca980503056 sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents: 59
diff changeset
128 if (throwable is null) return super.toString ();
0
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
129 return super.toString () ~ " (" ~ throwable.toString () ~ ")"; //$NON-NLS-1$ //$NON-NLS-2$
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
130 }
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
131
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
132 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
133 * Outputs a printable representation of this exception's
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
134 * stack trace on the standard error stream.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
135 * <p>
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
136 * Note: printStackTrace(PrintStream) and printStackTrace(PrintWriter)
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
137 * are not provided in order to maintain compatibility with CLDC.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
138 * </p>
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
139 */
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
140 public void printStackTrace () {
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
141 Stderr.formatln( "stacktrace follows (if feature compiled in)" );
59
dc7db4338dbe MenuItem
Frank Benoit <benoit@tionex.de>
parents: 57
diff changeset
142 foreach( msg; info ){
0
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
143 Stderr.formatln( "{}", msg );
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
144 }
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
145 if ( throwable !is null) {
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
146 Stderr.formatln ("*** Stack trace of contained exception ***"); //$NON-NLS-1$
59
dc7db4338dbe MenuItem
Frank Benoit <benoit@tionex.de>
parents: 57
diff changeset
147 foreach( msg; throwable.info ){
0
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
148 Stderr.formatln( "{}", msg );
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
149 }
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
150 }
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
151 }
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
152
4
bf9fe45b4422 C, Platform, Point, Rectangle
Frank Benoit <benoit@tionex.de>
parents: 0
diff changeset
153 }
0
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
154
206
cca980503056 sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents: 59
diff changeset
155