Mercurial > projects > dwt-linux
annotate dwt/DWTException.d @ 259:c0d810de7093
Update SWT 3.4M7 to 3.4
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 29 Jun 2008 14:33:38 +0200 |
parents | 380bad9f6852 |
children | 4bffbf81e2d6 |
rev | line source |
---|---|
72 | 1 /******************************************************************************* |
259 | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
0 | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
72 | 10 * Port to the D programming language: |
11 * Frank Benoit <benoit@tionex.de> | |
0 | 12 *******************************************************************************/ |
71 | 13 module dwt.DWTException; |
0 | 14 |
238 | 15 import dwt.dwthelper.utils; |
16 | |
71 | 17 import dwt.DWT; |
0 | 18 |
19 import tango.core.Exception; | |
20 import tango.io.Stdout; | |
21 | |
22 /** | |
23 * This runtime exception is thrown whenever a recoverable error | |
71 | 24 * occurs internally in DWT. The message text and error code |
0 | 25 * provide a further description of the problem. The exception |
26 * has a <code>throwable</code> field which holds the underlying | |
27 * exception that caused the problem (if this information is | |
28 * available (i.e. it may be null)). | |
29 * <p> | |
30 * SWTExceptions are thrown when something fails internally, | |
71 | 31 * but DWT is left in a known stable state (eg. a widget call |
0 | 32 * was made from a non-u/i thread, or there is failure while |
33 * reading an Image because the source file was corrupt). | |
34 * </p> | |
35 * | |
71 | 36 * @see DWTError |
259 | 37 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> |
0 | 38 */ |
39 | |
158
de2578a843a7
Tango update to rev 3158, TracedException>Exception, fromUtf8z>fromStringz,Fix Bug in MenuItem Thanx to nascent for the report.
Frank Benoit <benoit@tionex.de>
parents:
72
diff
changeset
|
40 public class DWTException : Exception { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
41 /** |
71 | 42 * The DWT error code, one of DWT.ERROR_*. |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
43 */ |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
44 public int code; |
0 | 45 |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
46 /** |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
47 * The underlying throwable that caused the problem, |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
48 * or null if this information is not available. |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
49 */ |
231
654b7d7cc33c
instead of throwable member var, use the Exception.next
Frank Benoit <benoit@tionex.de>
parents:
158
diff
changeset
|
50 public Exception throwable( Exception e ){ |
654b7d7cc33c
instead of throwable member var, use the Exception.next
Frank Benoit <benoit@tionex.de>
parents:
158
diff
changeset
|
51 this.next = e; |
654b7d7cc33c
instead of throwable member var, use the Exception.next
Frank Benoit <benoit@tionex.de>
parents:
158
diff
changeset
|
52 return this.next; |
654b7d7cc33c
instead of throwable member var, use the Exception.next
Frank Benoit <benoit@tionex.de>
parents:
158
diff
changeset
|
53 } |
654b7d7cc33c
instead of throwable member var, use the Exception.next
Frank Benoit <benoit@tionex.de>
parents:
158
diff
changeset
|
54 public Exception throwable(){ |
654b7d7cc33c
instead of throwable member var, use the Exception.next
Frank Benoit <benoit@tionex.de>
parents:
158
diff
changeset
|
55 return this.next; |
654b7d7cc33c
instead of throwable member var, use the Exception.next
Frank Benoit <benoit@tionex.de>
parents:
158
diff
changeset
|
56 } |
654b7d7cc33c
instead of throwable member var, use the Exception.next
Frank Benoit <benoit@tionex.de>
parents:
158
diff
changeset
|
57 |
0 | 58 |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
59 //static final long serialVersionUID = 3257282552304842547L; |
0 | 60 |
61 /** | |
62 * Constructs a new instance of this class with its | |
63 * stack trace filled in. The error code is set to an | |
64 * unspecified value. | |
65 */ | |
66 public this () { | |
71 | 67 this (DWT.ERROR_UNSPECIFIED); |
0 | 68 } |
69 | |
70 /** | |
71 * Constructs a new instance of this class with its | |
72 * stack trace and message filled in. The error code is | |
73 * set to an unspecified value. Specifying <code>null</code> | |
74 * as the message is equivalent to specifying an empty string. | |
75 * | |
76 * @param message the detail message for the exception | |
77 */ | |
238 | 78 public this (String message) { |
71 | 79 this (DWT.ERROR_UNSPECIFIED, message); |
0 | 80 } |
81 | |
82 /** | |
83 * Constructs a new instance of this class with its | |
84 * stack trace and error code filled in. | |
85 * | |
71 | 86 * @param code the DWT error code |
0 | 87 */ |
88 public this (int code) { | |
71 | 89 this (code, DWT.findErrorText (code)); |
0 | 90 } |
91 | |
92 /** | |
93 * Constructs a new instance of this class with its | |
94 * stack trace, error code and message filled in. | |
95 * Specifying <code>null</code> as the message is | |
96 * equivalent to specifying an empty string. | |
97 * | |
71 | 98 * @param code the DWT error code |
0 | 99 * @param message the detail message for the exception |
100 */ | |
238 | 101 public this (int code, String message) { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
102 super (message); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
103 this.code = code; |
0 | 104 } |
105 | |
106 /** | |
107 * Returns the underlying throwable that caused the problem, | |
108 * or null if this information is not available. | |
109 * <p> | |
110 * NOTE: This method overrides Throwable.getCause() that was | |
111 * added to JDK1.4. It is necessary to override this method | |
112 * in order for inherited printStackTrace() methods to work. | |
113 * </p> | |
114 * @return the underlying throwable | |
115 * | |
116 * @since 3.1 | |
117 */ | |
158
de2578a843a7
Tango update to rev 3158, TracedException>Exception, fromUtf8z>fromStringz,Fix Bug in MenuItem Thanx to nascent for the report.
Frank Benoit <benoit@tionex.de>
parents:
72
diff
changeset
|
118 public Exception getCause() { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
119 return throwable; |
0 | 120 } |
121 | |
122 /** | |
71 | 123 * Returns the string describing this DWTException object. |
0 | 124 * <p> |
125 * It is combined with the message string of the Throwable | |
71 | 126 * which caused this DWTException (if this information is available). |
0 | 127 * </p> |
71 | 128 * @return the error message string of this DWTException object |
0 | 129 */ |
238 | 130 public String getMessage () { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
131 if (throwable is null) return super.toString (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
132 return super.toString () ~ " (" ~ throwable.toString () ~ ")"; //$NON-NLS-1$ //$NON-NLS-2$ |
0 | 133 } |
134 | |
135 /** | |
136 * Outputs a printable representation of this exception's | |
137 * stack trace on the standard error stream. | |
138 * <p> | |
139 * Note: printStackTrace(PrintStream) and printStackTrace(PrintWriter) | |
140 * are not provided in order to maintain compatibility with CLDC. | |
141 * </p> | |
142 */ | |
143 public void printStackTrace () { | |
144 Stderr.formatln( "stacktrace follows (if feature compiled in)" ); | |
158
de2578a843a7
Tango update to rev 3158, TracedException>Exception, fromUtf8z>fromStringz,Fix Bug in MenuItem Thanx to nascent for the report.
Frank Benoit <benoit@tionex.de>
parents:
72
diff
changeset
|
145 foreach( msg; info ){ |
0 | 146 Stderr.formatln( "{}", msg ); |
147 } | |
148 if ( throwable !is null) { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
149 Stderr.formatln ("*** Stack trace of contained exception ***"); //$NON-NLS-1$ |
158
de2578a843a7
Tango update to rev 3158, TracedException>Exception, fromUtf8z>fromStringz,Fix Bug in MenuItem Thanx to nascent for the report.
Frank Benoit <benoit@tionex.de>
parents:
72
diff
changeset
|
150 foreach( msg; throwable.info ){ |
0 | 151 Stderr.formatln( "{}", msg ); |
152 } | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
153 } |
0 | 154 } |
155 | |
156 } | |
157 | |
158 |