author | Stefan Vogel <sv@exept.de> |
Fri, 23 Jul 1999 20:13:00 +0200 | |
changeset 4447 | b41133d7941b |
parent 4445 | 7011a3da6c72 |
child 4449 | c8e195e21aab |
permissions | -rw-r--r-- |
1 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
171 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
Object subclass:#Exception |
|
1118
1037616d9add
ignore unhandled querySignals
Claus Gittinger <cg@exept.de>
parents:
1038
diff
changeset
|
14 |
instanceVariableNames:'signal parameter errorString suspendedContext handlerContext |
4438 | 15 |
rejected originator resumeBlock rejectBlock proceedable' |
1118
1037616d9add
ignore unhandled querySignals
Claus Gittinger <cg@exept.de>
parents:
1038
diff
changeset
|
16 |
classVariableNames:'EmergencyHandler RecursiveExceptionSignal' |
1037616d9add
ignore unhandled querySignals
Claus Gittinger <cg@exept.de>
parents:
1038
diff
changeset
|
17 |
poolDictionaries:'' |
1037616d9add
ignore unhandled querySignals
Claus Gittinger <cg@exept.de>
parents:
1038
diff
changeset
|
18 |
category:'Kernel-Exceptions' |
1 | 19 |
! |
20 |
||
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
21 |
Exception class instanceVariableNames:'NotifierString' |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
22 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
23 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
24 |
The following class instance variables are inherited by this class: |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
25 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
26 |
Object - |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
27 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
28 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
29 |
|
1953
c8a3af54acb3
unhandled querySignals should return nil
Claus Gittinger <cg@exept.de>
parents:
1710
diff
changeset
|
30 |
!Exception class methodsFor:'documentation'! |
12 | 31 |
|
88 | 32 |
copyright |
33 |
" |
|
34 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
171 | 35 |
All Rights Reserved |
88 | 36 |
|
37 |
This software is furnished under a license and may be used |
|
38 |
only in accordance with the terms of that license and with the |
|
39 |
inclusion of the above copyright notice. This software may not |
|
40 |
be provided or otherwise made available to, or used by, any |
|
41 |
other person. No title to or ownership of the software is |
|
42 |
hereby transferred. |
|
43 |
" |
|
44 |
! |
|
45 |
||
12 | 46 |
documentation |
47 |
" |
|
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
48 |
Exception and its subclasses implement the same protocal as Signal. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
49 |
So class based exceptions may be implemented as subclasses of Exception. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
50 |
|
68 | 51 |
Instances of Exception are passed to a Signal handling block as argument. |
52 |
The handler block may perform various actions by sending corresponding messages |
|
142 | 53 |
to the exception object. The following actions are possible: |
1 | 54 |
|
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
55 |
reject - dont handle this signal; |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
56 |
another handler will be searched for, |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
57 |
upper in the calling hierarchy |
1 | 58 |
|
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
59 |
proceed - return from the Signal>>raise, with nil as value |
142 | 60 |
|
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
61 |
proceedWith:val - same, but return val from Signal>>raise |
1 | 62 |
|
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
63 |
return - return from the Signal>>handle:do:, with nil as value |
142 | 64 |
|
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
65 |
returnWith:val - same, but return val from Signal>>handle:do: |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
66 |
(this is also the handlers default, |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
67 |
if it falls through; taking the handlerBlocks value |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
68 |
as return value) |
1 | 69 |
|
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
70 |
restart - restart the Signal>>handle:do:, after repairing |
1 | 71 |
|
142 | 72 |
Via the Exception object, the handler can also query the state of execution: |
68 | 73 |
where the Signal was raised, where the handler is, the signal which caused |
142 | 74 |
the error and the errorString passed when the signal was raised. Also, an optional |
75 |
parameter can be passed - the use is signal specific.: |
|
44 | 76 |
|
1274 | 77 |
[instance variables:] |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
78 |
signal <Signal> the signal which caused the exception |
142 | 79 |
|
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
80 |
parameter <Object> a parameter (if any) which was passed when raising |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
81 |
the signal (only if raised with #raiseWith:aParameter) |
142 | 82 |
|
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
83 |
errorString <String> an errorString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
84 |
(usually the signals own errorString, but sometimes |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
85 |
changed explicitely in #raiseWith:errorString:) |
44 | 86 |
|
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
87 |
suspendedContext <Context> the context in which the raise occured |
142 | 88 |
|
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
89 |
handlerContext <Context> the context of the handler (if any) |
142 | 90 |
|
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
91 |
resumeBlock <Block> private to the exception; needed to perform resume action |
44 | 92 |
|
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
93 |
rejectBlock <Block> private to the exception; needed to perform reject action |
44 | 94 |
|
142 | 95 |
In case of an unhandled signal raise, Exceptions EmergenyHandler will be evaluated. |
68 | 96 |
The default emergeny handler will enter the debugger. |
142 | 97 |
|
68 | 98 |
For applications, which do not want Debuggers to come up, other handlers are |
99 |
possible. |
|
362 | 100 |
For example, to get the typical C++ behavior, use: |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
101 |
Exception emergencyHandler:[:ex | Smalltalk exitWithCoreDump] |
68 | 102 |
|
1274 | 103 |
|
104 |
[Class variables:] |
|
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
105 |
EmergencyHandler <Block> this block is evaluated, if no handler was defined |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
106 |
for a signal (i.e. this one is responsible for the |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
107 |
unhandled exception debugger). |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
108 |
Having this being a block allows to globally catch |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
109 |
these errors - even when no enclosing handler-scope |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
110 |
around the erronous code exists. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
111 |
(as the catch/through does). |
171 | 112 |
|
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
113 |
RecursiveExceptionSignal |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
114 |
<Signal> raised when within a handler for some signal, |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
115 |
the same signal is raised again. |
1274 | 116 |
|
117 |
||
118 |
[see also:] |
|
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
119 |
Signal SignalSet QuerySignal |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
120 |
Context Block |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
121 |
Object DebugView |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
122 |
(``Exception handling and signals'': programming/exceptions.html) |
1292 | 123 |
|
124 |
[author:] |
|
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
125 |
Claus Gittinger |
12 | 126 |
" |
2174 | 127 |
! |
128 |
||
129 |
examples |
|
130 |
" |
|
131 |
Examples on Exception-raising & handling are found in the doc/coding |
|
132 |
section (CodingExamples). |
|
133 |
||
134 |
The emergencyHandler stuff is very useful, to prevent endUser applications |
|
135 |
from entering the debugger. |
|
136 |
Some commonly used (useful) emergency handlers are provided in the |
|
137 |
'useful handlers' section; try them to learn more |
|
138 |
(especially, the mailingHandler is fun). |
|
139 |
||
2219 | 140 |
Of course, these are only examples - you may define your own handler |
141 |
block and pass it to the #emergencyHandler: method. |
|
142 |
||
143 |
BTW: the Launchers 'source & debugger' settings menu allows you |
|
144 |
to install either a default or the notifying handler. |
|
145 |
||
146 |
||
147 |
A handler which shows a box, then aborts - (no more debuggers): |
|
148 |
[exBegin] |
|
149 |
Exception emergencyHandler:(Exception abortingEmergencyHandler) |
|
150 |
[exEnd] |
|
151 |
||
152 |
||
153 |
A handler which aborts - (no box, no debugger): |
|
154 |
[exBegin] |
|
155 |
Exception emergencyHandler:[:ex | AbortSignal raise] |
|
156 |
[exEnd] |
|
2174 | 157 |
|
158 |
||
159 |
try some exception (for demonstration, in some other process): |
|
2219 | 160 |
[exBegin] |
161 |
[ |
|
162 |
#(1 2 3) at:4 |
|
163 |
] fork. |
|
164 |
[exEnd] |
|
2174 | 165 |
|
2219 | 166 |
cleanup (switch back to the regular handler, which enters the debugger): |
167 |
[exBegin] |
|
168 |
Exception emergencyHandler:nil |
|
169 |
[exEnd] |
|
170 |
||
171 |
||
172 |
A handler which shows a warnBox and asks for debugging: |
|
173 |
[exBegin] |
|
174 |
Exception emergencyHandler:(Exception notifyingEmergencyHandler) |
|
175 |
[exEnd] |
|
176 |
||
2174 | 177 |
|
178 |
||
179 |
A handler which dumps information to a file (watch the file 'errorTrace.stx'): |
|
2219 | 180 |
[exBegin] |
181 |
Exception emergencyHandler:(Exception dumpingEmergencyHandler) |
|
182 |
[exEnd] |
|
183 |
||
184 |
||
2174 | 185 |
|
186 |
A handler which sends you mail: |
|
2219 | 187 |
[exBegin] |
188 |
Exception emergencyHandler:(Exception mailingEmergencyHandler) |
|
189 |
[exEnd] |
|
2174 | 190 |
" |
12 | 191 |
! ! |
3 | 192 |
|
1953
c8a3af54acb3
unhandled querySignals should return nil
Claus Gittinger <cg@exept.de>
parents:
1710
diff
changeset
|
193 |
!Exception class methodsFor:'initialization'! |
171 | 194 |
|
195 |
initialize |
|
196 |
"setup the signal used to handle unhandled signals" |
|
197 |
||
198 |
RecursiveExceptionSignal isNil ifTrue:[ |
|
302 | 199 |
RecursiveExceptionSignal := ErrorSignal newSignalMayProceed:false. |
171 | 200 |
RecursiveExceptionSignal nameClass:self message:#recursiveExceptionSignal. |
201 |
RecursiveExceptionSignal notifierString:'recursive signal raise in handler' |
|
202 |
] |
|
203 |
! ! |
|
204 |
||
1953
c8a3af54acb3
unhandled querySignals should return nil
Claus Gittinger <cg@exept.de>
parents:
1710
diff
changeset
|
205 |
!Exception class methodsFor:'instance creation'! |
621 | 206 |
|
4441 | 207 |
signal:aSignal originator:origin |
208 |
"create a new instance and set the fields in preparation for a raise. |
|
209 |
- only to be sent from the signal when raising" |
|
210 |
||
211 |
"{ Pragma: +inlineNew }" |
|
212 |
||
213 |
^ (self basicNew) signal:aSignal originator:origin. |
|
214 |
||
215 |
"Created: / 23.7.1999 / 13:40:45 / stefan" |
|
216 |
! |
|
217 |
||
621 | 218 |
signal:aSignal parameter:aParameter errorString:aString suspendedContext:sContext originator:origin |
219 |
"create a new instance and set the fields in preparation for a raise. |
|
220 |
- only to be sent from the signal when raising" |
|
221 |
||
3091 | 222 |
"{ Pragma: +inlineNew }" |
223 |
||
3017 | 224 |
^ (self basicNew) |
621 | 225 |
signal:aSignal |
226 |
parameter:aParameter |
|
227 |
errorString:aString |
|
228 |
suspendedContext:sContext |
|
229 |
originator:origin. |
|
230 |
! ! |
|
231 |
||
1953
c8a3af54acb3
unhandled querySignals should return nil
Claus Gittinger <cg@exept.de>
parents:
1710
diff
changeset
|
232 |
!Exception class methodsFor:'Signal constants'! |
171 | 233 |
|
234 |
recursiveExceptionSignal |
|
235 |
"return the signal used to handle recursive signals in the handlers" |
|
236 |
||
237 |
^ RecursiveExceptionSignal |
|
238 |
! ! |
|
239 |
||
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
240 |
!Exception class methodsFor:'compatibility - accessing'! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
241 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
242 |
errorString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
243 |
"return the notifier string. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
244 |
If the notifier string starts with space, prepend |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
245 |
the parents notifier string" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
246 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
247 |
NotifierString isNil ifTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
248 |
^ self parent errorString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
249 |
] ifFalse:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
250 |
(NotifierString size > 0 |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
251 |
and:[NotifierString first == (Character space)]) ifTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
252 |
^ self parent errorString, NotifierString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
253 |
] ifFalse:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
254 |
^ NotifierString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
255 |
]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
256 |
] |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
257 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
258 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
259 |
Object errorSignal errorString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
260 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
261 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
262 |
"Created: / 23.7.1999 / 14:22:25 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
263 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
264 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
265 |
errorStringExtra:extraString with:aParameter |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
266 |
"used when raising with a given error string and/or parameter; |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
267 |
if the errorString starts with a space, it is appended to the receivers |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
268 |
notifier string; if it ends with a space, it is prepended. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
269 |
Otherwise, the extraString is returned. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
270 |
If no extraString is given, use the signals default errorString." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
271 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
272 |
|t| |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
273 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
274 |
(self inheritsFrom:Object userNotificationSignal) ifTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
275 |
"/ all userNotifications pass the extraString unchanged. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
276 |
^ extraString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
277 |
]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
278 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
279 |
extraString isNil ifTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
280 |
t := self errorString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
281 |
] ifFalse:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
282 |
t := extraString. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
283 |
(extraString endsWith:Character space) ifTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
284 |
t := extraString, self errorString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
285 |
] ifFalse:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
286 |
(extraString startsWith:Character space) ifTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
287 |
t := self errorString, extraString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
288 |
] |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
289 |
]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
290 |
]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
291 |
^ t. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
292 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
293 |
"/ aParameter isNil ifTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
294 |
"/ ^ t |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
295 |
"/ ]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
296 |
"/ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
297 |
"/ (t startsWith:' ') ifTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
298 |
"/ ^ aParameter printString , t |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
299 |
"/ ]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
300 |
"/ (t endsWith:' ') ifTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
301 |
"/ ^ t , aParameter printString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
302 |
"/ ]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
303 |
"/ ^ t |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
304 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
305 |
"Modified: / 25.3.1997 / 12:12:37 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
306 |
"Created: / 23.7.1999 / 14:23:38 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
307 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
308 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
309 |
handlerBlock |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
310 |
"Compatibility with Signal. Class based exeption do not have a handler |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
311 |
block. They redefine the #action method instead" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
312 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
313 |
^ nil |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
314 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
315 |
"Created: / 23.7.1999 / 14:43:18 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
316 |
! ! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
317 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
318 |
!Exception class methodsFor:'compatibility - queries'! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
319 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
320 |
accepts:aSignal |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
321 |
"return true, if the receiver accepts the argument, aSignal. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
322 |
(i.e. the receiver is aSignal or a parent of it). False otherwise." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
323 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
324 |
|s| |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
325 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
326 |
aSignal isQuerySignal ifTrue:[^ false]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
327 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
328 |
s := aSignal. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
329 |
[s notNil] whileTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
330 |
self == s ifTrue:[^ true]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
331 |
s := s parent |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
332 |
]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
333 |
^ false |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
334 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
335 |
"Created: / 23.7.1999 / 14:00:47 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
336 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
337 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
338 |
inheritsFrom:anotherSignal |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
339 |
"return true, if the receiver is a child of anotherSignal |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
340 |
(i.e. if handling anotherSignal also handles the receiver) |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
341 |
This is almost the same as accepts, but returns false, if |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
342 |
the receiver is identical to anotherSignal." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
343 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
344 |
self == anotherSignal ifTrue:[^ false]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
345 |
^ anotherSignal accepts:self |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
346 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
347 |
"Created: / 23.7.1999 / 13:59:51 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
348 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
349 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
350 |
isHandled |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
351 |
"return true, if there is a handler for the receiver signal. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
352 |
Raising an unhandled signal will usually lead into the debugger, |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
353 |
but can be caught globally by setting Exceptions EmergencyHandler." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
354 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
355 |
^ self isHandledIn:(thisContext sender). |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
356 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
357 |
"Created: / 23.7.1999 / 14:03:50 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
358 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
359 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
360 |
isHandledIn:aContext |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
361 |
"return true, if there is a handler for the receiver signal in the |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
362 |
contextChain starting with aContext." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
363 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
364 |
|con r| |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
365 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
366 |
con := aContext. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
367 |
[con notNil] whileTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
368 |
con := con findNextContextWithSelector:#'handle:do:' or:#'handle:from:do:' or:nil. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
369 |
con notNil ifTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
370 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
371 |
is this is a #handle:do: or a #handle:from:do: context |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
372 |
with self in it ? |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
373 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
374 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
375 |
((r := con receiver) notNil |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
376 |
and:[r accepts:self]) ifTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
377 |
"found a handler context" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
378 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
379 |
^ true |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
380 |
] |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
381 |
] |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
382 |
]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
383 |
^ false |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
384 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
385 |
"Created: / 23.7.1999 / 14:03:34 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
386 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
387 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
388 |
isQuerySignal |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
389 |
"return true, if this is a querySignal - always return false here" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
390 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
391 |
^ false |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
392 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
393 |
"Created: / 23.7.1999 / 13:50:16 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
394 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
395 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
396 |
isSignal |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
397 |
"return true, if the receiver is some kind of signal; |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
398 |
true returned here - the method is redefined from Object." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
399 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
400 |
^ true |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
401 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
402 |
"Created: / 23.7.1999 / 13:49:59 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
403 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
404 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
405 |
mayProceed |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
406 |
"return true, if the exception handler is allowed to proceed |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
407 |
the execution where the exception occured. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
408 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
409 |
Subclasses may redefine this." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
410 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
411 |
^ true |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
412 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
413 |
"Modified: / 23.7.1999 / 14:50:11 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
414 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
415 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
416 |
parent |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
417 |
"return the parent Signal/Exception of myself. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
418 |
Subclasses may redefine this to install themself as child of |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
419 |
existing Signals." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
420 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
421 |
self == Exception ifTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
422 |
^ nil |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
423 |
]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
424 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
425 |
^ superclass |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
426 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
427 |
"Created: / 23.7.1999 / 14:01:29 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
428 |
"Modified: / 23.7.1999 / 16:15:38 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
429 |
! ! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
430 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
431 |
!Exception class methodsFor:'compatibility - raising'! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
432 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
433 |
newException |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
434 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
435 |
^ self new signal:self. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
436 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
437 |
"Created: / 23.7.1999 / 13:45:49 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
438 |
"Modified: / 23.7.1999 / 13:53:12 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
439 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
440 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
441 |
newExceptionFrom:originator |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
442 |
"answer a new exception object for this signal. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
443 |
Set the originator. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
444 |
Subclasses may redefine this method" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
445 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
446 |
^ self new originator:originator |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
447 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
448 |
"Created: / 23.7.1999 / 13:47:07 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
449 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
450 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
451 |
raise |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
452 |
"raise a signal nonproceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
453 |
The signals notifierString is used as errorString." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
454 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
455 |
^ self newException raise |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
456 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
457 |
"Modified: / 2.5.1996 / 16:36:23 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
458 |
"Modified: / 5.3.1998 / 16:44:36 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
459 |
"Created: / 23.7.1999 / 14:07:17 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
460 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
461 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
462 |
raiseErrorString:aString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
463 |
"raise a signal nonproceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
464 |
The argument is used as errorString." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
465 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
466 |
^ (self newException errorString:aString) raise. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
467 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
468 |
"Modified: / 9.5.1996 / 15:17:59 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
469 |
"Modified: / 12.3.1998 / 15:15:22 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
470 |
"Created: / 23.7.1999 / 14:07:33 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
471 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
472 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
473 |
raiseErrorString:aString in:aContext |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
474 |
"raise a signal nonproceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
475 |
The argument is used as errorString. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
476 |
The additional context is passed as the context responsible for the raise, |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
477 |
allowing a raise to mimicri the exception happened somewhere else." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
478 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
479 |
^ (self newException |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
480 |
signal:self |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
481 |
parameter:nil |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
482 |
errorString:aString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
483 |
suspendedContext:aContext |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
484 |
originator:nil) raise. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
485 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
486 |
"Modified: / 26.7.1996 / 16:42:47 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
487 |
"Modified: / 12.3.1998 / 15:43:43 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
488 |
"Created: / 23.7.1999 / 14:07:48 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
489 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
490 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
491 |
raiseFrom:something |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
492 |
"raise a signal nonproceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
493 |
The argument, something is passed both as parameter and originator." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
494 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
495 |
^ ((self newExceptionFrom:something) parameter:something) raise |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
496 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
497 |
"Modified: / 2.5.1996 / 16:36:38 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
498 |
"Modified: / 5.3.1998 / 16:49:55 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
499 |
"Created: / 23.7.1999 / 14:07:59 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
500 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
501 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
502 |
raiseIn:aContext |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
503 |
"raise a signal nonproceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
504 |
The signals notifierString is used as errorString. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
505 |
The additional context is passed as the context responsible for the raise, |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
506 |
allowing a raise to mimicri the exception happened somewhere else." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
507 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
508 |
^ (self newException suspendedContext:aContext) raise. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
509 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
510 |
"Modified: / 2.5.1996 / 16:36:44 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
511 |
"Modified: / 5.3.1998 / 16:50:21 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
512 |
"Created: / 23.7.1999 / 14:08:13 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
513 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
514 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
515 |
raiseRequest |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
516 |
"raise a signal proceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
517 |
The signals notifierString is used as errorString." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
518 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
519 |
^ self newException raiseRequest. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
520 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
521 |
"Modified: / 2.5.1996 / 16:36:52 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
522 |
"Modified: / 5.3.1998 / 16:50:46 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
523 |
"Created: / 23.7.1999 / 14:08:24 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
524 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
525 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
526 |
raiseRequestFrom:something |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
527 |
"raise a signal proceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
528 |
The argument, something is passed both as parameter and originator." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
529 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
530 |
^ ((self newExceptionFrom:something) parameter:something) raiseRequest. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
531 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
532 |
"Modified: / 2.5.1996 / 16:36:38 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
533 |
"Modified: / 5.3.1998 / 16:52:46 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
534 |
"Created: / 23.7.1999 / 14:08:36 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
535 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
536 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
537 |
raiseRequestWith:aParameter |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
538 |
"raise a signal proceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
539 |
The signals notifierString is used as errorString." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
540 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
541 |
^ (self newException parameter:aParameter) raiseRequest. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
542 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
543 |
"Modified: / 9.5.1996 / 15:13:20 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
544 |
"Modified: / 12.3.1998 / 15:16:57 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
545 |
"Created: / 23.7.1999 / 14:08:48 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
546 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
547 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
548 |
raiseRequestWith:aParameter errorString:aString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
549 |
"raise a signal proceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
550 |
The argument, aString is used as errorString." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
551 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
552 |
^ (self newException |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
553 |
parameter:aParameter; |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
554 |
errorString:aString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
555 |
) raiseRequest |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
556 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
557 |
"Modified: / 9.5.1996 / 15:13:35 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
558 |
"Modified: / 12.3.1998 / 15:17:52 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
559 |
"Created: / 23.7.1999 / 14:08:57 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
560 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
561 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
562 |
raiseRequestWith:aParameter errorString:aString in:aContext |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
563 |
"raise a signal proceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
564 |
The argument, aString is used as errorString. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
565 |
The additional context is passed as the context responsible for the raise, |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
566 |
allowing a raise to mimicri the exception happened somewhere else." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
567 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
568 |
^ (self newException |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
569 |
parameter:aParameter; |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
570 |
errorString:aString; |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
571 |
suspendedContext:aContext) raiseRequest |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
572 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
573 |
"Modified: / 26.7.1996 / 16:29:27 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
574 |
"Modified: / 12.3.1998 / 15:18:34 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
575 |
"Created: / 23.7.1999 / 14:09:07 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
576 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
577 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
578 |
raiseRequestWith:aParameter in:aContext |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
579 |
"raise a signal proceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
580 |
The signals notifierString is used as errorString. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
581 |
The additional context is passed as the context responsible for the raise, |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
582 |
allowing a raise to mimicri the exception happened somewhere else." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
583 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
584 |
^ (self newException |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
585 |
parameter:aParameter; |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
586 |
suspendedContext:aContext) raiseRequest. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
587 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
588 |
"Modified: / 26.7.1996 / 16:29:33 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
589 |
"Modified: / 12.3.1998 / 15:18:55 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
590 |
"Created: / 23.7.1999 / 14:09:17 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
591 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
592 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
593 |
raiseWith:aParameter |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
594 |
"raise a signal nonproceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
595 |
The argument, aParameter is passed as parameter." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
596 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
597 |
^ (self newException parameter:aParameter) raise. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
598 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
599 |
"Modified: / 9.5.1996 / 15:14:24 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
600 |
"Modified: / 12.3.1998 / 15:19:11 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
601 |
"Created: / 23.7.1999 / 14:09:27 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
602 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
603 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
604 |
raiseWith:aParameter errorString:aString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
605 |
"raise a signal nonproceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
606 |
The argument, aString is used as errorString, aParameter is passed |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
607 |
as exception parameter." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
608 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
609 |
^ (self newException |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
610 |
parameter:aParameter; |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
611 |
errorString:aString) raise. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
612 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
613 |
"Modified: / 9.5.1996 / 15:14:32 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
614 |
"Modified: / 12.3.1998 / 15:19:40 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
615 |
"Created: / 23.7.1999 / 14:09:36 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
616 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
617 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
618 |
raiseWith:aParameter errorString:aString in:aContext |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
619 |
"raise a signal nonproceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
620 |
The argument, aString is used as errorString, aParameter is passed |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
621 |
as exception parameter. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
622 |
The additional context is passed as the context responsible for the raise, |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
623 |
allowing a raise to mimicri the exception happened somewhere else." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
624 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
625 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
626 |
^ (self newException |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
627 |
parameter:aParameter; |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
628 |
errorString:aString; |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
629 |
suspendedContext:aContext) raise. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
630 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
631 |
"Modified: / 26.7.1996 / 16:29:42 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
632 |
"Modified: / 12.3.1998 / 15:20:12 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
633 |
"Created: / 23.7.1999 / 14:09:46 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
634 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
635 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
636 |
raiseWith:aParameter in:aContext |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
637 |
"raise a signal nonproceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
638 |
The argument, aParameter is passed as parameter." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
639 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
640 |
^ (self newException parameter:aParameter; |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
641 |
suspendedContext:aContext) raise. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
642 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
643 |
"Modified: / 9.5.1996 / 15:14:24 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
644 |
"Modified: / 12.3.1998 / 15:34:51 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
645 |
"Created: / 23.7.1999 / 14:10:04 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
646 |
! ! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
647 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
648 |
!Exception class methodsFor:'compatibility - save evaluation'! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
649 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
650 |
catch:aBlock |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
651 |
"evaluate the argument, aBlock. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
652 |
If the receiver-signal is raised during evaluation, abort |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
653 |
the evaluation and return true; otherwise return false. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
654 |
This is the catch & throw mechanism found in other languages, |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
655 |
where the returned value indicates if an exception occured." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
656 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
657 |
|raiseOccurred| |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
658 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
659 |
raiseOccurred := false. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
660 |
self handle:[:ex | raiseOccurred := true. ex return] do:aBlock. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
661 |
^ raiseOccurred |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
662 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
663 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
664 |
Object messageNotUnderstoodSignal catch:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
665 |
123 size open |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
666 |
] |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
667 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
668 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
669 |
"Created: / 23.7.1999 / 14:06:01 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
670 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
671 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
672 |
handle:handleBlock do:aBlock |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
673 |
"evaluate the argument, aBlock. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
674 |
If the receiver-signal is raised during evaluation, |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
675 |
evaluate the handleBlock passing it an Exception argument. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
676 |
The handler may decide how to react to the signal by sending |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
677 |
a corresponding message to the exception (see there). |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
678 |
If the signal is not raised, return the value of evaluating |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
679 |
aBlock." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
680 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
681 |
^ aBlock value "the real logic is in Exception>>doRaise" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
682 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
683 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
684 |
Object messageNotUnderstoodSignal handle:[:ex | |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
685 |
'oops' printNL. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
686 |
ex return |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
687 |
] do:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
688 |
123 size open |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
689 |
] |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
690 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
691 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
692 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
693 |
|num| |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
694 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
695 |
num := 0. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
696 |
Number divisionByZeroSignal handle:[:ex | |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
697 |
'oops' printNL. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
698 |
ex return |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
699 |
] do:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
700 |
123 / num |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
701 |
] |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
702 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
703 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
704 |
"Modified: / 2.3.1998 / 14:28:26 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
705 |
"Created: / 23.7.1999 / 14:06:13 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
706 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
707 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
708 |
handle:handleBlock from:anObject do:aBlock |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
709 |
"evaluate the argument, aBlock. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
710 |
If the receiver-signal is raised during evaluation, |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
711 |
and the exception originated from anObject, |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
712 |
evaluate the handleBlock passing it an Exception argument. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
713 |
The handler may decide how to react to the signal by sending |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
714 |
a corresponding message to the exception (see there). |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
715 |
If the signal is not raised, return the value of evaluating |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
716 |
aBlock." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
717 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
718 |
^ aBlock value "the real logic is in Exception>>doRaise" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
719 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
720 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
721 |
the first open will be caught; the second not: |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
722 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
723 |
|o1 o2| |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
724 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
725 |
o1 := 123. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
726 |
o2 := nil. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
727 |
Object messageNotUnderstoodSignal |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
728 |
handle: |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
729 |
[:ex | |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
730 |
'oops' printNL. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
731 |
ex proceed |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
732 |
] |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
733 |
from:o1 |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
734 |
do: |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
735 |
[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
736 |
o1 open. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
737 |
o2 open |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
738 |
] |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
739 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
740 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
741 |
"Modified: / 2.3.1998 / 14:28:05 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
742 |
"Created: / 23.7.1999 / 14:06:26 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
743 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
744 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
745 |
ignoreIn:aBlock |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
746 |
"evaluate the argument, aBlock. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
747 |
Ignore the receiver-signal during evaluation - i.e. simply |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
748 |
continue. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
749 |
This makes only sense for some signals, such as UserInterrupt |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
750 |
or AbortSignal, because continuing after an exception without any cleanup |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
751 |
often leads to followup-errors." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
752 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
753 |
^ self handle:[:ex | ex proceed] do:aBlock. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
754 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
755 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
756 |
Object messageNotUnderstoodSignal ignoreIn:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
757 |
123 size open |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
758 |
] |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
759 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
760 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
761 |
"Created: / 23.7.1999 / 14:06:40 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
762 |
! ! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
763 |
|
4447 | 764 |
!Exception class methodsFor:'compatibility - signal creation'! |
765 |
||
766 |
newSignal |
|
767 |
"create a new signal, using the receiver as a prototype and |
|
768 |
setting the parent of the new signal to the receiver." |
|
769 |
||
770 |
^ self newSignalMayProceed:self mayProceed |
|
771 |
||
772 |
"Created: / 23.7.1999 / 20:13:23 / stefan" |
|
773 |
! |
|
774 |
||
775 |
newSignalMayProceed:proceed |
|
776 |
"create a new signal, using the receiver as a prototype and |
|
777 |
setting the parent of the new signal to the receiver." |
|
778 |
||
779 |
^ (Signal basicNew) mayProceed:proceed; |
|
780 |
notifierString:NotifierString; |
|
781 |
parent:self |
|
782 |
||
783 |
"Created: / 23.7.1999 / 20:12:43 / stefan" |
|
784 |
! ! |
|
785 |
||
1953
c8a3af54acb3
unhandled querySignals should return nil
Claus Gittinger <cg@exept.de>
parents:
1710
diff
changeset
|
786 |
!Exception class methodsFor:'defaults'! |
12 | 787 |
|
788 |
emergencyHandler |
|
2174 | 789 |
"return the handler used for unhandled exceptions. |
790 |
||
791 |
If no EmergencyHandler has been set, a handler which enters the |
|
792 |
debugger is returned. |
|
793 |
The debugger is opened by asking the signal for a debug action, |
|
794 |
this allows to provide other debuggers in specialized (subclass-instances) |
|
795 |
of Signal (if that is ever needed)" |
|
12 | 796 |
|
77 | 797 |
" |
798 |
set it up, when called the first time |
|
799 |
" |
|
800 |
EmergencyHandler isNil ifTrue:[ |
|
2208 | 801 |
EmergencyHandler := [:ex | |
802 |
" |
|
803 |
sending it to the signal allows per-signal specific |
|
804 |
debuggers to be implemented in the future |
|
805 |
(for example, segv in primitive code could show things |
|
806 |
on the C-level ..) |
|
807 |
" |
|
808 |
(ex signal) enterDebuggerWith:ex message:(ex errorString). |
|
809 |
] |
|
77 | 810 |
]. |
811 |
||
12 | 812 |
^ EmergencyHandler |
2174 | 813 |
|
814 |
"Modified: 15.1.1997 / 20:50:37 / cg" |
|
12 | 815 |
! |
816 |
||
130 | 817 |
emergencyHandler:aOneArgBlock |
2174 | 818 |
"set the handler used for unhandled exceptions. |
819 |
The default (a nil-handler) leads to a debugger to be shown." |
|
12 | 820 |
|
130 | 821 |
EmergencyHandler := aOneArgBlock |
362 | 822 |
|
823 |
"ST-80 behavior of first showing a notifier: |
|
824 |
(I prefer to get right into the debugger, though) |
|
825 |
||
826 |
Exception |
|
2208 | 827 |
emergencyHandler: |
828 |
[:ex | self errorNotify:ex errorString ] |
|
2081 | 829 |
" |
830 |
||
831 |
"ST-X behavior of going right into the debugger: |
|
832 |
||
833 |
Exception |
|
2208 | 834 |
emergencyHandler:nil |
362 | 835 |
" |
836 |
||
837 |
"automatically aborting current operation, on error: |
|
838 |
(may be useful for end-user apps; make certain, |
|
839 |
you have abortSignal handlers at appropriate places) |
|
840 |
||
841 |
Exception |
|
2208 | 842 |
emergencyHandler: |
843 |
[:ex | Object abortSignal raise. ex return. ] |
|
362 | 844 |
" |
845 |
||
846 |
"finally, traditional language system behavior; dump core ;-) |
|
847 |
||
848 |
Exception |
|
2208 | 849 |
emergencyHandler: |
850 |
[:ex | Smalltalk exitWithCoreDump. ] |
|
362 | 851 |
" |
2081 | 852 |
|
2174 | 853 |
"Modified: 15.1.1997 / 20:49:06 / cg" |
854 |
! ! |
|
855 |
||
856 |
!Exception class methodsFor:'useful handlers'! |
|
857 |
||
858 |
abortingEmergencyHandler |
|
859 |
"return a block (usable as an emergency handler), |
|
860 |
which aborts after showing a warnBox. |
|
861 |
This is useful for endUser applications" |
|
862 |
||
863 |
^ [:ex | self warn:'Error: ' , ex errorString. |
|
2208 | 864 |
AbortSignal raise |
2174 | 865 |
] |
866 |
||
867 |
"test with (try a few halts or CTRL-C's): |
|
868 |
Exception emergencyHandler:(Exception abortingEmergencyHandler) |
|
869 |
" |
|
870 |
||
871 |
"back with: |
|
872 |
Exception emergencyHandler:(Exception notifyingEmergencyHandler) |
|
873 |
Exception emergencyHandler:nil |
|
874 |
" |
|
875 |
||
876 |
"Created: 15.1.1997 / 20:13:06 / cg" |
|
877 |
"Modified: 15.1.1997 / 20:15:02 / cg" |
|
878 |
! |
|
879 |
||
880 |
dumpingEmergencyHandler |
|
881 |
"return a block (usable as an emergency handler), |
|
882 |
which dumps the stackBacktrace to a trace file and |
|
883 |
aborts after showing a warnBox. |
|
884 |
This is useful, for endUser application, which are still being |
|
885 |
debugged (i.e. the programmers may have a look at the traceFile |
|
886 |
from time to time). |
|
887 |
||
888 |
Notice: |
|
2257 | 889 |
The code below is just an example; you may want to change the |
890 |
name of the error-file in your application |
|
891 |
(but please: copy the code; do not modify here)" |
|
2174 | 892 |
|
893 |
^ [:ex | |
|
2257 | 894 |
|str printedException| |
2174 | 895 |
|
2257 | 896 |
ex signal == Signal noHandlerSignal ifTrue:[ |
897 |
printedException := ex parameter. |
|
898 |
] ifFalse:[ |
|
899 |
printedException := ex |
|
900 |
]. |
|
901 |
||
902 |
"/ user interruption is handled specially: |
|
903 |
"/ allow user to choose between proceeding or aborting |
|
904 |
"/ but never dump that information to the file. |
|
2174 | 905 |
|
2257 | 906 |
printedException signal == Object userInterruptSignal ifTrue:[ |
907 |
(self confirm:'abort current action ?') ifTrue:[ |
|
908 |
AbortSignal raise |
|
909 |
]. |
|
910 |
ex proceed |
|
911 |
]. |
|
2174 | 912 |
|
2257 | 913 |
"/ |
914 |
"/ dump it to 'errorTrace.stx' |
|
915 |
"/ |
|
916 |
str := 'errorTrace.stx' asFilename appendingWriteStream. |
|
2174 | 917 |
|
2257 | 918 |
str nextPutLine:('******************************* ' |
919 |
, AbsoluteTime now printString |
|
920 |
, ' *******************************'). |
|
921 |
str cr. |
|
2174 | 922 |
|
2257 | 923 |
str nextPutLine:('** Error: ' , printedException errorString). |
924 |
str nextPutLine:('** Signal: ' , printedException signal printString). |
|
925 |
str nextPutLine:('** Parameter: ' , printedException parameter printString). |
|
926 |
str nextPutLine:('** Process: ' , Processor activeProcess printString). |
|
927 |
str nextPutLine:('** Backtrace:'). |
|
928 |
str cr. |
|
2174 | 929 |
|
2257 | 930 |
printedException suspendedContext fullPrintAllOn:str. |
931 |
str cr. |
|
932 |
str cr. |
|
933 |
str close. |
|
2174 | 934 |
|
2257 | 935 |
"/ send a line to stdErr |
936 |
||
937 |
('[warning]: ignored error: ' , printedException errorString) errorPrintCR. |
|
938 |
('[warning]: error information appended to ''errorTrace.stx''') errorPrintCR. |
|
939 |
||
940 |
AbortSignal raise |
|
2174 | 941 |
] |
942 |
||
943 |
"test with (try a few halts or CTRL-C's): |
|
944 |
Exception emergencyHandler:(Exception dumpingEmergencyHandler) |
|
945 |
" |
|
946 |
||
947 |
"back with: |
|
948 |
Exception emergencyHandler:(Exception notifyingEmergencyHandler) |
|
949 |
Exception emergencyHandler:nil |
|
950 |
" |
|
951 |
||
952 |
"Created: 15.1.1997 / 20:14:52 / cg" |
|
2257 | 953 |
"Modified: 24.1.1997 / 20:36:21 / cg" |
2174 | 954 |
! |
955 |
||
956 |
mailingEmergencyHandler |
|
957 |
"return a block (usable as an emergency handler), |
|
958 |
which shows a warnBox and optionally mails a stackBacktrace to a maintainer. |
|
959 |
This is useful, for endUser application, which are still being |
|
960 |
debugged (i.e. the programmers may have a look at the errors). |
|
961 |
||
962 |
Notice: the stuff here is a demonstration only; it should be modified |
|
2208 | 963 |
for your particular environment ... |
964 |
... but please: copy the code and modify there; |
|
965 |
leave the stuff below as it is." |
|
2174 | 966 |
|
967 |
^ [:ex | |
|
2208 | 968 |
|str printedException doMail emergencyMailReceiver pipe| |
2174 | 969 |
|
2208 | 970 |
ex signal == Signal noHandlerSignal ifTrue:[ |
971 |
printedException := ex parameter. |
|
972 |
] ifFalse:[ |
|
973 |
printedException := ex |
|
974 |
]. |
|
2174 | 975 |
|
2208 | 976 |
"/ user interruption is handled specially: |
977 |
"/ allow user to choose between proceeding or aborting |
|
978 |
"/ but never dump that information to the file. |
|
2174 | 979 |
|
2208 | 980 |
printedException signal == Object userInterruptSignal ifTrue:[ |
981 |
(self confirm:'abort current action ?') ifTrue:[ |
|
982 |
AbortSignal raise |
|
983 |
]. |
|
984 |
ex proceed |
|
985 |
]. |
|
2174 | 986 |
|
2208 | 987 |
"/ somehow get the name of the guy to receive the mail |
988 |
"/ you have to implement that yourself. |
|
2174 | 989 |
|
2208 | 990 |
"/ emergencyMailReceiver := OneOfYourClass getEmergencyMailReceiver. |
991 |
emergencyMailReceiver := OperatingSystem getLoginName. |
|
2174 | 992 |
|
2208 | 993 |
emergencyMailReceiver isNil ifTrue:[ |
994 |
self warn:(printedException errorString |
|
995 |
, '\\No mailing to service people possible.') withCRs. |
|
996 |
doMail := false. |
|
997 |
] ifFalse:[ |
|
998 |
doMail := self confirm:(printedException errorString |
|
999 |
, '\\Mail error information to the service people (' |
|
1000 |
, emergencyMailReceiver , ') ?') withCRs |
|
1001 |
]. |
|
1002 |
doMail ifTrue:[ |
|
1003 |
str := '' writeStream. |
|
2174 | 1004 |
|
2208 | 1005 |
str nextPutLine:('Error notification from ' |
1006 |
, OperatingSystem getLoginName |
|
1007 |
, '@' |
|
1008 |
, OperatingSystem getHostName). |
|
1009 |
str cr. |
|
2174 | 1010 |
|
2208 | 1011 |
str nextPutLine:('Time: ' , AbsoluteTime now printString). |
1012 |
str nextPutLine:('Error: ', printedException errorString). |
|
1013 |
str nextPutLine:('Signal: ', printedException signal printString). |
|
1014 |
str nextPutLine:('Parameter: ', printedException parameter printString). |
|
1015 |
str nextPutLine:('Process: ', Processor activeProcess printString). |
|
1016 |
str nextPutLine:'Backtrace:'. |
|
1017 |
str cr. |
|
2174 | 1018 |
|
2208 | 1019 |
printedException suspendedContext fullPrintAllOn:str. |
1020 |
str cr;cr. |
|
2174 | 1021 |
|
2208 | 1022 |
str close. |
2174 | 1023 |
|
2208 | 1024 |
pipe := PipeStream |
1025 |
writingTo:'mail ', emergencyMailReceiver. |
|
1026 |
pipe notNil ifTrue:[ |
|
1027 |
pipe nextPutLine:'Subject: automatic error report'. |
|
1028 |
pipe nextPutAll:str contents. |
|
1029 |
pipe cr. |
|
1030 |
pipe close. |
|
1031 |
] |
|
1032 |
]. |
|
2174 | 1033 |
|
2208 | 1034 |
AbortSignal raise |
2174 | 1035 |
] |
1036 |
||
1037 |
"test with (try a few halts or CTRL-C's): |
|
1038 |
Exception emergencyHandler:(Exception mailingEmergencyHandler) |
|
1039 |
" |
|
1040 |
||
1041 |
"back with: |
|
1042 |
Exception emergencyHandler:(Exception notifyingEmergencyHandler) |
|
1043 |
Exception emergencyHandler:nil |
|
1044 |
" |
|
1045 |
||
1046 |
"Created: 15.1.1997 / 20:14:52 / cg" |
|
1047 |
"Modified: 15.1.1997 / 21:10:28 / cg" |
|
1048 |
! |
|
1049 |
||
1050 |
notifyingEmergencyHandler |
|
1051 |
"return a block (usable as an emergency handler for exceptions), |
|
1052 |
which does errorNotification before going into the debugger." |
|
1053 |
||
1054 |
^ [:ex | nil errorNotify:ex errorString from:ex suspendedContext ] |
|
1055 |
||
1056 |
"test with (try a few halts or CTRL-C's): |
|
1057 |
Exception emergencyHandler:(Exception notifyingEmergencyHandler) |
|
1058 |
" |
|
1059 |
||
1060 |
"back with: |
|
1061 |
Exception emergencyHandler:nil |
|
1062 |
" |
|
1063 |
||
1064 |
"Modified: 15.1.1997 / 20:15:12 / cg" |
|
362 | 1065 |
! ! |
1066 |
||
1 | 1067 |
!Exception methodsFor:'accessing'! |
1068 |
||
44 | 1069 |
errorString |
1070 |
"return the errorString passsed with the signal raise |
|
1071 |
(or nil, if there was none)" |
|
1072 |
||
4438 | 1073 |
^ signal errorStringExtra:errorString with:nil |
1074 |
||
1075 |
"Modified: / 12.3.1998 / 15:13:28 / stefan" |
|
1076 |
! |
|
1077 |
||
1078 |
errorString:aString |
|
1079 |
"set the errorString. |
|
1080 |
If it starts with a space, the signals errorString is prepended, |
|
1081 |
if it ends with a space, it is appended." |
|
1082 |
||
1083 |
errorString := aString |
|
1084 |
||
1085 |
"Created: / 5.3.1998 / 16:45:29 / stefan" |
|
1086 |
"Modified: / 12.3.1998 / 15:30:45 / stefan" |
|
44 | 1087 |
! |
1088 |
||
621 | 1089 |
handlerContext |
1090 |
"return the context of the handler" |
|
1091 |
||
1092 |
^ handlerContext |
|
1093 |
! |
|
1094 |
||
362 | 1095 |
originator |
1096 |
"return the originator passsed with the signal raise |
|
1097 |
(or nil, if there was none)" |
|
1098 |
||
1099 |
^ originator |
|
1100 |
! |
|
1101 |
||
4438 | 1102 |
originator:anObject |
1103 |
"set the originator" |
|
1104 |
||
1105 |
originator := anObject |
|
1106 |
||
1107 |
"Created: / 5.3.1998 / 16:34:56 / stefan" |
|
1108 |
! |
|
1109 |
||
621 | 1110 |
parameter |
1111 |
"return the parameter passsed with the signal raise |
|
1112 |
(or nil, if there was none)" |
|
44 | 1113 |
|
621 | 1114 |
^ parameter |
68 | 1115 |
! |
1116 |
||
4438 | 1117 |
parameter:anObject |
1118 |
"set the parameter of the exception" |
|
1119 |
||
1120 |
parameter := anObject |
|
1121 |
||
1122 |
"Created: / 5.3.1998 / 16:34:22 / stefan" |
|
1123 |
! |
|
1124 |
||
68 | 1125 |
rejected |
362 | 1126 |
"return true, if any other of the exceptions handlers has rejected |
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
1127 |
Uncertain, if this is really interesting to anybody. |
362 | 1128 |
This is only valid during handler execution. |
1129 |
(i.e. an outer handler can find out, if any other handler has already |
|
1130 |
rejected). |
|
1131 |
" |
|
68 | 1132 |
|
1133 |
^ rejected |
|
362 | 1134 |
! |
1135 |
||
621 | 1136 |
signal |
1137 |
"return the signal, that caused the exception" |
|
1138 |
||
1139 |
^ signal |
|
1140 |
! |
|
1141 |
||
4438 | 1142 |
signal:aSignal |
1143 |
"set the signal, that caused the exception" |
|
1144 |
||
1145 |
signal := aSignal |
|
1146 |
||
1147 |
"Created: / 5.3.1998 / 16:02:46 / stefan" |
|
1148 |
! |
|
1149 |
||
621 | 1150 |
suspendedContext |
1151 |
"return the context in which the raise occured" |
|
1152 |
||
1153 |
^ suspendedContext |
|
1154 |
! |
|
1155 |
||
4438 | 1156 |
suspendedContext:something |
1157 |
"set the value of the instance variable 'suspendedContext' (automatically generated)" |
|
1158 |
||
1159 |
suspendedContext := something. |
|
1160 |
||
1161 |
"Created: / 2.3.1998 / 12:43:20 / stefan" |
|
1162 |
! |
|
1163 |
||
362 | 1164 |
willProceed |
1165 |
"return true, if the exception is proceedable" |
|
1166 |
||
4438 | 1167 |
^ resumeBlock notNil and:[proceedable] |
1168 |
||
1169 |
"Modified: / 2.3.1998 / 12:20:43 / stefan" |
|
1170 |
! ! |
|
1171 |
||
1172 |
!Exception methodsFor:'copying'! |
|
1173 |
||
1174 |
postCopy |
|
1175 |
"set the internal state to nil" |
|
1176 |
||
1177 |
suspendedContext := handlerContext := rejected := nil |
|
1178 |
||
1179 |
"Created: / 2.3.1998 / 12:30:06 / stefan" |
|
1 | 1180 |
! ! |
1181 |
||
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1182 |
!Exception methodsFor:'default actions'! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1183 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1184 |
action |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1185 |
"perform a action for the signal if it hasn't been catched |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1186 |
We arrive here, if either no handler was found, or none of the |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1187 |
handlers did a return (i.e. every handler rejected or fell through). |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1188 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1189 |
The default is to evaluate the signal's handlerBlock. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1190 |
Subclasses may redefine this." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1191 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1192 |
|block noHandlerSignal msg| |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1193 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1194 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1195 |
try per signal handler |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1196 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1197 |
(block := signal handlerBlock) isNil ifTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1198 |
"/ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1199 |
"/ if its a querySignal, ignore it |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1200 |
"/ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1201 |
signal isQuerySignal ifTrue:[^ nil]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1202 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1203 |
"/ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1204 |
"/ if it is not the NoHandlerSignal, raise it ... |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1205 |
"/ passing the receiver as parameter. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1206 |
"/ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1207 |
signal ~~ (noHandlerSignal := Signal noHandlerSignal) ifTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1208 |
noHandlerSignal notNil ifTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1209 |
handlerContext notNil ifTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1210 |
msg := 'unhandled (rejected)' |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1211 |
] ifFalse:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1212 |
msg := 'unhandled' |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1213 |
]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1214 |
msg := msg , ' exception: (' , self errorString , ')'. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1215 |
^ noHandlerSignal |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1216 |
raiseRequestWith:self |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1217 |
errorString:msg |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1218 |
in:self suspendedContext |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1219 |
]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1220 |
"/ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1221 |
"/ mhmh - an error during early startup; noHandlerSignal is |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1222 |
"/ not yet defined. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1223 |
"/ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1224 |
^ MiniDebugger enterWithMessage:self errorString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1225 |
]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1226 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1227 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1228 |
mhmh - smells like trouble - there is no handler and |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1229 |
no per-signal handler block. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1230 |
Look for either a per-process emergencyHandlerBlock |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1231 |
or the global emergencyHandler (from Exception) ... |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1232 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1233 |
Processor notNil ifTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1234 |
"care for signal during startup (Processor not yet created)" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1235 |
block := Processor activeProcess emergencySignalHandler. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1236 |
]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1237 |
block isNil ifTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1238 |
block := Exception emergencyHandler. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1239 |
block isNil ifTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1240 |
"care for error during startup (Exception not yet initialized)" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1241 |
^ MiniDebugger enterWithMessage:self errorString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1242 |
]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1243 |
]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1244 |
]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1245 |
"... and call it" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1246 |
^ block value:self. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1247 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1248 |
"Created: / 23.7.1999 / 14:38:03 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1249 |
"Modified: / 23.7.1999 / 14:41:36 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1250 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1251 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1252 |
mayProceed |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1253 |
"return true, if the exception handler is allowed to proceed |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1254 |
the execution where the exception occured. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1255 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1256 |
Subclasses may redefine this." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1257 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1258 |
^ signal mayProceed |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1259 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1260 |
"Created: / 23.7.1999 / 14:48:26 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1261 |
! ! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1262 |
|
621 | 1263 |
!Exception methodsFor:'handler actions'! |
1264 |
||
1265 |
proceed |
|
1266 |
"Continue after the raise - the raise returns nil" |
|
1267 |
||
2509
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1268 |
|b| |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1269 |
|
4438 | 1270 |
resumeBlock isNil ifTrue:[ |
1271 |
"signal raiser does not want us to proceed" |
|
1272 |
Signal proceedErrorSignal raiseWith:self. |
|
1273 |
] ifFalse:[ |
|
1274 |
proceedable ifFalse:[ |
|
1275 |
('WARNING: signal <', signal printString, '> has been raised nonproceedable') errorPrintCR. |
|
1276 |
(' by: ', suspendedContext printString) errorPrintCR. |
|
1277 |
(' ', thisContext sender printString , ' tries to proceed.') errorPrintCR. |
|
1278 |
(' This will be an error in future ST/X versions.') errorPrintCR. |
|
1279 |
]. |
|
2509
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1280 |
b := resumeBlock. |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1281 |
resumeBlock := rejectBlock := handlerContext := suspendedContext := nil. |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1282 |
b value:nil |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1283 |
] |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1284 |
|
4438 | 1285 |
" |
1286 |
Object errorSignal handle:[:ex| |
|
1287 |
ex proceed |
|
1288 |
] do:[ |
|
1289 |
Object errorSignal raise |
|
1290 |
]. |
|
1291 |
" |
|
1292 |
||
1293 |
"Modified: / 27.3.1997 / 16:44:39 / cg" |
|
1294 |
"Modified: / 2.3.1998 / 12:00:10 / stefan" |
|
621 | 1295 |
! |
1296 |
||
1297 |
proceedWith:value |
|
1298 |
"Continue after the raise - the raise returns value" |
|
1299 |
||
2509
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1300 |
|b| |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1301 |
|
4438 | 1302 |
resumeBlock isNil ifTrue:[ |
1303 |
"signal raiser does not want us to proceed" |
|
1304 |
Signal proceedErrorSignal raiseWith:self. |
|
1305 |
] ifFalse:[ |
|
1306 |
proceedable ifFalse:[ |
|
1307 |
('WARNING: signal <', signal printString, '> has been raised nonproceedable') errorPrintCR. |
|
1308 |
(' by: ', suspendedContext printString) errorPrintCR. |
|
1309 |
(' ', thisContext sender printString , ' tries to proceed.') errorPrintCR. |
|
1310 |
(' This will be an error in future ST/X versions.') errorPrintCR. |
|
1311 |
]. |
|
2509
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1312 |
b := resumeBlock. |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1313 |
resumeBlock := rejectBlock := handlerContext := suspendedContext := nil. |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1314 |
b value:value |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1315 |
] |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1316 |
|
4438 | 1317 |
"Modified: / 27.3.1997 / 16:45:57 / cg" |
1318 |
"Modified: / 2.3.1998 / 12:02:06 / stefan" |
|
621 | 1319 |
! |
1 | 1320 |
|
621 | 1321 |
reject |
1322 |
"handler decided not to handle this signal - |
|
1323 |
system will look for another handler" |
|
1324 |
||
1325 |
rejected := true. |
|
1326 |
rejectBlock value |
|
1327 |
! |
|
1328 |
||
1329 |
restart |
|
1330 |
"restart the handle:do: - usually after some repair work is done |
|
1331 |
in handler" |
|
1332 |
||
1333 |
handlerContext unwindAndRestart |
|
1334 |
! |
|
1 | 1335 |
|
3100 | 1336 |
restartDo:aBlock |
1337 |
"restart the handle:do: but execute the argument, aBlock instead of the |
|
1338 |
original do-block - usually after some repair work is done in handler" |
|
1339 |
||
1340 |
handlerContext argAt:2 put:aBlock. |
|
1341 |
handlerContext unwindAndRestart |
|
1342 |
||
1343 |
" |
|
1344 |
|sig rslt| |
|
1345 |
||
1346 |
sig := Signal new. |
|
1347 |
||
1348 |
sig handle:[:ex | |
|
1349 |
ex restartDo:[ rslt := 999 ] |
|
1350 |
] do:[ |
|
1351 |
rslt := 0. |
|
1352 |
sig raise |
|
1353 |
]. |
|
1354 |
||
1355 |
Transcript showCR:rslt |
|
1356 |
" |
|
1357 |
||
1358 |
"Modified: / 8.11.1997 / 18:52:28 / cg" |
|
1359 |
! |
|
1360 |
||
621 | 1361 |
resume |
4438 | 1362 |
"Continue after the raise - the raise returns nil |
1363 |
obsolete (use #proceed), retained for backwards compatibility" |
|
2509
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1364 |
|
4438 | 1365 |
self obsoleteMethodWarning:'use #proceed'. |
1366 |
^ self proceed |
|
2509
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1367 |
|
4438 | 1368 |
"Modified: / 2.3.1998 / 10:51:55 / stefan" |
621 | 1369 |
! |
1370 |
||
1371 |
resumeWith:value |
|
4438 | 1372 |
"Continue after the raise - the raise returns value |
1373 |
obsolete (use #proceedWith:), retained for backwards compatibility" |
|
2509
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1374 |
|
4438 | 1375 |
self obsoleteMethodWarning:'use #proceedWith:'. |
1376 |
^ self proceedWith:value |
|
2509
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1377 |
|
4438 | 1378 |
"Modified: / 2.3.1998 / 10:51:48 / stefan" |
621 | 1379 |
! |
1380 |
||
1381 |
return |
|
1382 |
"Continue after the handle:do: - the handle:do: returns nil" |
|
1383 |
||
2509
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1384 |
|con| |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1385 |
|
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1386 |
con := handlerContext. |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1387 |
resumeBlock := rejectBlock := handlerContext := suspendedContext := nil. |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1388 |
con unwind |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1389 |
|
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1390 |
"Modified: 27.3.1997 / 16:46:39 / cg" |
621 | 1391 |
! |
1392 |
||
1393 |
returnDoing:aBlock |
|
1394 |
"Continue after the handle:do: - the handle:do: returns aBlock value" |
|
1395 |
||
1396 |
handlerContext unwindThenDo:aBlock |
|
1397 |
! |
|
1398 |
||
1399 |
returnWith:value |
|
1400 |
"Continue after the handle:do: - the handle:do: returns value" |
|
1401 |
||
2509
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1402 |
|con| |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1403 |
|
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1404 |
con := handlerContext. |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1405 |
resumeBlock := rejectBlock := handlerContext := suspendedContext := nil. |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1406 |
con unwind:value |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1407 |
|
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1408 |
"Modified: 27.3.1997 / 16:46:51 / cg" |
171 | 1409 |
! ! |
1410 |
||
4438 | 1411 |
!Exception methodsFor:'private'! |
1 | 1412 |
|
621 | 1413 |
doCallHandler:aHandler |
1414 |
"call the handler proper - needed an extra method |
|
1415 |
to have a separate returnContext for the rejectBlock. |
|
1416 |
(which is historical, and actually no longer needed)" |
|
1417 |
||
1418 |
|val| |
|
362 | 1419 |
|
621 | 1420 |
rejectBlock := [^ self]. "this will return on reject" |
1421 |
val := aHandler value:self. |
|
1422 |
" |
|
1423 |
handler fall through - is just like a returnWith:blocks-value |
|
1424 |
" |
|
2291
af7652b82404
avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents:
2282
diff
changeset
|
1425 |
rejectBlock := nil. |
621 | 1426 |
self returnWith:val |
1 | 1427 |
! |
1428 |
||
1378
056b3a0928f2
oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
1429 |
doRaise |
171 | 1430 |
"search through the context-calling chain for a 'handle:do:'-context |
1609
21f69f2adef7
when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1431 |
to the raising signal, a parent of it, or a SignalSet which includes |
171 | 1432 |
the raising signal. |
1433 |
If found, take the contexts 2nd argument (the handler) and evaluate |
|
1434 |
it with the receiver exception as argument. |
|
217 | 1435 |
If no handler is found, try per signal handler, or |
1436 |
per process handler (if its the noHandlerSignal). |
|
1437 |
Finally fall back to Exceptions emergencyHandler, which is always |
|
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1438 |
available and enters the debugger. |
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1439 |
ATTENTION: the code below depends on being called by #raise or |
1609
21f69f2adef7
when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1440 |
#raiseRequest for proper operation (it skips the sending context)." |
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1441 |
|
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1442 |
|theContext block noHandlerSignal conArg1 |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1443 |
theSignal c ex1 activeHandlers inHandler |
3509 | 1444 |
lastHandler h r firstHandler| |
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1445 |
|
4438 | 1446 |
"/ is nil a valid originator? If so, we need an extra |
1447 |
"/ instanceVariable to record the originator setting. |
|
1448 |
||
1449 |
originator isNil ifTrue:[ |
|
1450 |
originator := suspendedContext homeReceiver |
|
1451 |
]. |
|
1452 |
||
3100 | 1453 |
theSignal := signal. |
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1454 |
theSignal isSignal ifFalse:[ |
2282 | 1455 |
self halt:'unexpected non-Signal in calling context'. |
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1456 |
]. |
171 | 1457 |
|
1609
21f69f2adef7
when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1458 |
"/ 'search handler for: ' print. theSignal displayString printCR. |
21f69f2adef7
when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1459 |
|
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1460 |
inHandler := false. |
3100 | 1461 |
c := thisContext sender sender. "the raise/raiseRequest-context" |
1462 |
"the signal raise context" |
|
1609
21f69f2adef7
when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1463 |
|
2204 | 1464 |
"/ since the exceptionHandler is evaluated onTop of the |
1465 |
"/ contextChain, we must skip active handlers before searching. |
|
1466 |
"/ otherwise, we get into trouble, when re-raising an exception |
|
1467 |
"/ from within a handler (which would lead to re-executing the |
|
1468 |
"/ same handler) |
|
1469 |
"/ the code below collects active handlers ... |
|
1470 |
||
3066 | 1471 |
"/ on the fly, look for the first #handle:do: - context, |
1472 |
"/ and remember it (as firstHandler) to avoid walking the context chain twice |
|
1473 |
"/ in most cases ... |
|
2291
af7652b82404
avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents:
2282
diff
changeset
|
1474 |
|
3066 | 1475 |
firstHandler := nil. |
2208 | 1476 |
|
3066 | 1477 |
[c notNil] whileTrue:[ |
1478 |
firstHandler isNil ifTrue:[ |
|
1479 |
c := c findNextContextWithSelector:#doRaise or:#'handle:do:' or:#'handle:from:do:'. |
|
1480 |
] ifFalse:[ |
|
1481 |
c := c findNextContextWithSelector:#doRaise or:nil or:nil. |
|
1482 |
]. |
|
1483 |
c notNil ifTrue:[ |
|
1484 |
(c selector == #doRaise) ifTrue:[ |
|
1609
21f69f2adef7
when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1485 |
|
3066 | 1486 |
ex1 := c receiver. |
1487 |
||
1488 |
((ex1 class == self class) |
|
1489 |
or:[ex1 species == self species]) ifTrue:[ |
|
4438 | 1490 |
(ex1 signal == theSignal) ifTrue:[ |
3110 | 1491 |
h := ex1 handlerContext. |
1492 |
h notNil ifTrue:[ |
|
1493 |
r := h receiver. |
|
1494 |
(r notNil and:[r accepts:theSignal]) ifTrue:[ |
|
1495 |
activeHandlers isNil ifTrue:[ |
|
1496 |
activeHandlers := OrderedCollection new |
|
1497 |
]. |
|
2208 | 1498 |
|
3110 | 1499 |
lastHandler := h. |
1500 |
activeHandlers add:lastHandler. |
|
1501 |
inHandler := true. |
|
1502 |
c := lastHandler. |
|
3066 | 1503 |
] |
2282 | 1504 |
] |
1505 |
] |
|
1506 |
] |
|
3066 | 1507 |
] ifFalse:[ |
1508 |
"/ must be a #handle:do context ... |
|
1509 |
firstHandler := c. |
|
2291
af7652b82404
avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents:
2282
diff
changeset
|
1510 |
] |
2282 | 1511 |
] |
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1512 |
]. |
171 | 1513 |
|
2208 | 1514 |
"/ now, start searching for a handler, |
3066 | 1515 |
"/ start search above the last active handler. |
1516 |
"/ Or start with the first handle:do: context, if one |
|
1517 |
"/ was found as a side effect of the previous handler search. |
|
1518 |
"/ If nil, then there is no handler and we can directly proceed |
|
1519 |
"/ to the unhandled code below. |
|
2208 | 1520 |
|
3179
f22e94c6ae83
oops - handler within a handler block did not catch
Claus Gittinger <cg@exept.de>
parents:
3111
diff
changeset
|
1521 |
"/ lastHandler notNil ifTrue:[ |
f22e94c6ae83
oops - handler within a handler block did not catch
Claus Gittinger <cg@exept.de>
parents:
3111
diff
changeset
|
1522 |
"/ theContext := lastHandler. |
f22e94c6ae83
oops - handler within a handler block did not catch
Claus Gittinger <cg@exept.de>
parents:
3111
diff
changeset
|
1523 |
"/ theContext := lastHandler findNextContextWithSelector:#'handle:do:' or:#'handle:from:do:' or:nil. |
f22e94c6ae83
oops - handler within a handler block did not catch
Claus Gittinger <cg@exept.de>
parents:
3111
diff
changeset
|
1524 |
"/ ] ifFalse:[ |
f22e94c6ae83
oops - handler within a handler block did not catch
Claus Gittinger <cg@exept.de>
parents:
3111
diff
changeset
|
1525 |
theContext := firstHandler. |
f22e94c6ae83
oops - handler within a handler block did not catch
Claus Gittinger <cg@exept.de>
parents:
3111
diff
changeset
|
1526 |
"/ ]. |
1609
21f69f2adef7
when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1527 |
|
2291
af7652b82404
avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents:
2282
diff
changeset
|
1528 |
[theContext notNil] whileTrue:[ |
3066 | 1529 |
(theContext selector == #'handle:do:' |
1530 |
or:[(theContext argAt:2) == originator]) |
|
1531 |
ifTrue:[ |
|
1532 |
(activeHandlers notNil |
|
1533 |
and:[activeHandlers includesIdentical:theContext]) ifTrue:[ |
|
3068 | 1534 |
"/ 'skip activeHandler: ' print. theContext displayString printCR. |
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1535 |
|
3066 | 1536 |
] ifFalse:[ |
1537 |
" |
|
1538 |
if this is the Signal>>handle:do: context |
|
1539 |
or a SignalSet>>handle:do: context with self in it, |
|
1540 |
call the handler |
|
1541 |
" |
|
1542 |
r := theContext receiver. |
|
1543 |
(r notNil and:[r accepts:signal]) ifTrue:[ |
|
1544 |
"call the handler" |
|
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1545 |
|
3066 | 1546 |
conArg1 := theContext argAt:1. |
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1547 |
|
3066 | 1548 |
handlerContext := theContext. |
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1549 |
|
3066 | 1550 |
self doCallHandler:conArg1. |
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1551 |
|
3066 | 1552 |
"/ if the handler rejects, we arrive here |
1553 |
"/ continue search for another handler |
|
1554 |
]. |
|
2291
af7652b82404
avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents:
2282
diff
changeset
|
1555 |
] |
3066 | 1556 |
]. |
1557 |
theContext := theContext findNextContextWithSelector:#'handle:do:' or:#'handle:from:do:' or:nil. |
|
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1558 |
]. |
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1559 |
|
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1560 |
activeHandlers := nil. |
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1561 |
|
171 | 1562 |
" |
1563 |
we arrive here, if either no handler was found, or none of the |
|
1564 |
handlers did a return (i.e. every handler rejected or fell through). |
|
1565 |
" |
|
1118
1037616d9add
ignore unhandled querySignals
Claus Gittinger <cg@exept.de>
parents:
1038
diff
changeset
|
1566 |
|
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1567 |
^ self action |
1118
1037616d9add
ignore unhandled querySignals
Claus Gittinger <cg@exept.de>
parents:
1038
diff
changeset
|
1568 |
|
3066 | 1569 |
"Created: / 12.5.1996 / 15:09:39 / cg" |
3100 | 1570 |
"Modified: / 9.11.1997 / 14:48:44 / cg" |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1571 |
"Modified: / 23.7.1999 / 14:40:12 / stefan" |
4438 | 1572 |
! ! |
1573 |
||
1574 |
!Exception methodsFor:'raising'! |
|
1378
056b3a0928f2
oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
1575 |
|
056b3a0928f2
oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
1576 |
raise |
4438 | 1577 |
"actually raise a non-proceedable exception |
1578 |
||
1579 |
In the past, ST/X did not distinguish between proceedable and |
|
1580 |
non-proceedable signals (signals invoked with #raise could proceed). |
|
1581 |
To allow a migration of old applications, we do not invoke a signal |
|
1582 |
but print out a warning, when trying to proceed a non-proceedable signal. |
|
1583 |
In the next release, this will raise a signal, so fix your code" |
|
1378
056b3a0928f2
oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
1584 |
|
4438 | 1585 |
suspendedContext isNil ifTrue:[ |
1586 |
"Call chain: |
|
1587 |
(origin)>>someMethod sender |
|
1588 |
Signal>>raise sender |
|
1589 |
Exception>>raise thisContext |
|
1590 |
" |
|
1591 |
suspendedContext := thisContext sender sender |
|
1592 |
]. |
|
1593 |
||
1594 |
"/ remove the next 2 lines to make proceeding from non-proceedable signals an error. |
|
1595 |
proceedable := false. |
|
1378
056b3a0928f2
oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
1596 |
resumeBlock := [:value | ^ value]. |
4438 | 1597 |
|
1378
056b3a0928f2
oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
1598 |
^ self doRaise |
056b3a0928f2
oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
1599 |
|
4438 | 1600 |
"Modified: / 12.5.1996 / 15:09:47 / cg" |
1601 |
"Modified: / 5.3.1998 / 16:40:23 / stefan" |
|
1 | 1602 |
! |
1603 |
||
621 | 1604 |
raiseRequest |
1605 |
"actually raise a proceedable exception." |
|
1 | 1606 |
|
4438 | 1607 |
suspendedContext isNil ifTrue:[ |
1608 |
"Call chain: |
|
1609 |
(origin)>>someMethod sender |
|
1610 |
Signal>>raise sender |
|
1611 |
Exception>>raise thisContext |
|
1612 |
" |
|
1613 |
suspendedContext := thisContext sender sender |
|
1614 |
]. |
|
1615 |
||
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1616 |
self mayProceed ifFalse:[ |
4438 | 1617 |
"/ proceeding from wrongProceedabilitySignal grants the raiseRequest |
1618 |
Signal wrongProceedabilitySignal raiseRequestWith:signal in:suspendedContext |
|
1619 |
]. |
|
1620 |
proceedable := true. |
|
1378
056b3a0928f2
oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
1621 |
resumeBlock := [:value | ^ value]. |
056b3a0928f2
oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
1622 |
^ self doRaise |
1376
6757590defbf
avoid extra send (raise->evaluateHandler)
Claus Gittinger <cg@exept.de>
parents:
1363
diff
changeset
|
1623 |
|
4438 | 1624 |
"Modified: / 12.5.1996 / 15:09:44 / cg" |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1625 |
"Modified: / 23.7.1999 / 14:48:48 / stefan" |
621 | 1626 |
! ! |
1 | 1627 |
|
621 | 1628 |
!Exception methodsFor:'setup'! |
1 | 1629 |
|
4441 | 1630 |
signal:aSignal originator:origin |
1631 |
"set the fields usable for inspection by the handler |
|
1632 |
- only to be sent from the signal when raising" |
|
1633 |
||
1634 |
signal := aSignal. |
|
1635 |
originator := origin. |
|
1636 |
||
1637 |
"Created: / 23.7.1999 / 13:39:35 / stefan" |
|
1638 |
! |
|
1639 |
||
621 | 1640 |
signal:aSignal parameter:aParameter errorString:aString suspendedContext:sContext originator:origin |
1641 |
"set the fields usable for inspection by the handler |
|
1642 |
- only to be sent from the signal when raising" |
|
328 | 1643 |
|
621 | 1644 |
signal := aSignal. |
1645 |
parameter := aParameter. |
|
1646 |
errorString := aString. |
|
1647 |
suspendedContext := sContext. |
|
1648 |
originator := origin. |
|
1649 |
! ! |
|
328 | 1650 |
|
1953
c8a3af54acb3
unhandled querySignals should return nil
Claus Gittinger <cg@exept.de>
parents:
1710
diff
changeset
|
1651 |
!Exception class methodsFor:'documentation'! |
662 | 1652 |
|
1653 |
version |
|
4447 | 1654 |
^ '$Header: /cvs/stx/stx/libbasic/Exception.st,v 1.69 1999-07-23 18:13:00 stefan Exp $' |
662 | 1655 |
! ! |
621 | 1656 |
Exception initialize! |