author | Claus Gittinger <cg@exept.de> |
Tue, 03 Aug 1999 14:55:02 +0200 | |
changeset 4513 | b16770982c62 |
parent 4506 | 731d94912596 |
child 4518 | 4716c8d7cb4c |
permissions | -rw-r--r-- |
1 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
4502 | 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:#Signal |
|
4506 | 14 |
instanceVariableNames:'mayProceed notifierString nameClass message handlerBlock parent' |
15 |
classVariableNames:'NoHandlerSignal GenericSignal ProceedErrorSignal |
|
16 |
WrongProceedabilitySignal' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Kernel-Exceptions' |
|
1 | 19 |
! |
20 |
||
2207 | 21 |
!Signal class methodsFor:'documentation'! |
44 | 22 |
|
88 | 23 |
copyright |
24 |
" |
|
25 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
4502 | 26 |
All Rights Reserved |
88 | 27 |
|
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
44 | 37 |
documentation |
38 |
" |
|
70 | 39 |
Signal and Exception provide a framework for exception handling. |
44 | 40 |
|
70 | 41 |
A Signal object is usually defined somewhere up in the calling chain |
42 |
and associated with some abnormal event. Many signals are also |
|
43 |
created at startup time and reused. |
|
44 | 44 |
|
70 | 45 |
When the event is raised (by Signal>>raise) the control will be either |
46 |
given to a debugger or - if a handler was defined - to the handler. |
|
47 |
The handler will get a description of what (and where) happened in an |
|
120 | 48 |
Exception object and can decide how to react on the situation (i.e. |
49 |
proceed, return or restart). |
|
70 | 50 |
|
51 |
There is also a companion class called SignalSet, which allows handling |
|
52 |
multiple signals with one handler (for example all arithmetic signals). |
|
53 |
And, finally there is a very special SignalSet which allows catching |
|
54 |
any signal (SignalSet>>anySignal). |
|
55 |
||
171 | 56 |
Since there is no official documentation on signal handling (i.e. none |
57 |
of the books describes it), this Signal implementation has been modeled |
|
58 |
after what some PD programs seem to expect and what alpha/beta testers told |
|
59 |
me it should look like. |
|
60 |
It may not be perfect and undergo minor changes. |
|
44 | 61 |
|
120 | 62 |
special: |
63 |
||
70 | 64 |
In addition to the nested catch & throw mechanism, signals can also be |
120 | 65 |
used when no such handler scope exists. To support this, signals can be |
66 |
assigned a handlerBlock, which gets evaluated with the exception as argument |
|
67 |
in case no handler was found (on the stack). |
|
70 | 68 |
|
171 | 69 |
If no handler was found (i.e. neither a handler context on the stack, nor |
70 |
a static handler block), the NoHandlerSignal will be raised instead, |
|
120 | 71 |
passing it the original exception in its exception-parameter. |
171 | 72 |
This NoHandlerSignal can be handled just like any other signal. |
73 |
(therefore, it is possible to catch any error by catching NoHandlerSignal. |
|
70 | 74 |
|
120 | 75 |
When the NoHandler signal is raised, and neither a handler-context, nor |
76 |
a handler block is defined for it, an emergencyHandler(-block) is evaluated. |
|
77 |
This block is either provided by the current process |
|
78 |
(see Process>>emergencySignalHandler) or as a global default by the Exception |
|
79 |
class (see Exception>>emergencyHandler). |
|
80 |
The default emergencyHandlerBlock (from Exception) will bring up a debugger. |
|
81 |
||
82 |
HandlerBlocks allow a global (if its the EmergencyHandler in Exception) |
|
83 |
or per-process signal handling to be added. Even to code which was never |
|
84 |
planned to handle signals. |
|
70 | 85 |
|
171 | 86 |
See samples in 'doc/coding' and actual raise code in Exception. |
1 | 87 |
|
1275 | 88 |
[Instance variables:] |
70 | 89 |
|
4502 | 90 |
mayProceed <Boolean> hint for the debugger - program may |
91 |
proceed (currently not honored by the |
|
92 |
debugger) |
|
1275 | 93 |
|
4502 | 94 |
notifierString <String> error message to be output |
70 | 95 |
|
4502 | 96 |
nameClass <Class> for the printOn-implementation; nameClass |
97 |
is the class, to which message (below) |
|
98 |
should be sent to create the receiver. |
|
1 | 99 |
|
4502 | 100 |
message <Symbol> for the printOn-implementation; message |
101 |
is the selector, which should be sent to |
|
102 |
nameClass (above) to create the receiver. |
|
1 | 103 |
|
4502 | 104 |
handlerBlock <Block> if nonNil, a 1-arg block to be |
105 |
evaluated when no handler context is |
|
106 |
found. The block gets the exception |
|
107 |
object as argument. This will play the role |
|
108 |
of an on-stack handler. |
|
1275 | 109 |
|
110 |
[Class variables:] |
|
70 | 111 |
|
4502 | 112 |
NoHandlerSignal <Signal> signal raised when no handler for a signal |
113 |
was found in raise. |
|
114 |
If this one is not handled either, |
|
115 |
Exceptions emergencyHandler will be evaluated |
|
116 |
instead (or a per-proces handler, if there |
|
117 |
is one). |
|
1292 | 118 |
|
119 |
[author:] |
|
4502 | 120 |
Claus Gittinger |
1292 | 121 |
|
1275 | 122 |
[see also:] |
4502 | 123 |
Exception |
124 |
SignalSet QuerySignal |
|
125 |
Object |
|
126 |
(``Exception handling and signals'': programming/exceptions.html) |
|
44 | 127 |
" |
128 |
! ! |
|
1 | 129 |
|
2207 | 130 |
!Signal class methodsFor:'initialization'! |
1 | 131 |
|
3004
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
132 |
initGenericSignal |
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
133 |
"setup the parent of all signals." |
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
134 |
|
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
135 |
GenericSignal isNil ifTrue:[ |
4438 | 136 |
GenericSignal := self basicNew notifierString: 'unknown Signal with: '. |
137 |
GenericSignal nameClass:self message:#genericSignal. |
|
138 |
GenericSignal mayProceed:true. |
|
3004
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
139 |
]. |
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
140 |
|
4438 | 141 |
"Modified: / 8.10.1997 / 11:58:01 / cg" |
142 |
"Modified: / 27.2.1998 / 14:17:20 / stefan" |
|
3004
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
143 |
! |
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
144 |
|
159 | 145 |
initialize |
44 | 146 |
"setup the signal used to handle unhandled signals" |
147 |
||
3004
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
148 |
GenericSignal isNil ifTrue:[ |
4438 | 149 |
self initGenericSignal. |
3010 | 150 |
]. |
3004
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
151 |
|
3010 | 152 |
NoHandlerSignal isNil ifTrue:[ |
4506 | 153 |
NoHandlerSignal := ErrorSignal newSignal |
154 |
nameClass:self message:#noHandlerSignal; |
|
155 |
notifierString:'unhandled exception'. |
|
156 |
ProceedErrorSignal := ErrorSignal newSignal |
|
157 |
nameClass:self message:#proceedErrorSignal; |
|
158 |
notifierString:'handler tried to proceed from nonproceedable exception'. |
|
159 |
WrongProceedabilitySignal := ErrorSignal newSignal |
|
160 |
nameClass:self message:#wrongProceedabilitySignal; |
|
161 |
notifierString:'attempt to raise a nonproceedable signal proceedable'. |
|
61 | 162 |
] |
3004
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
163 |
|
4438 | 164 |
"Modified: / 8.10.1997 / 11:48:40 / cg" |
4506 | 165 |
"Modified: / 3.8.1999 / 13:44:42 / stefan" |
1 | 166 |
! ! |
167 |
||
2207 | 168 |
!Signal class methodsFor:'instance creation'! |
1 | 169 |
|
170 |
new |
|
171 |
"return a new signal" |
|
172 |
||
4438 | 173 |
^ (self basicNew) notifierString:'signal'; mayProceed:true |
3004
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
174 |
|
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
175 |
" |
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
176 |
Signal new |
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
177 |
" |
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
178 |
|
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
179 |
"Modified: 8.10.1997 / 11:51:39 / cg" |
1 | 180 |
! ! |
181 |
||
2207 | 182 |
!Signal class methodsFor:'Signal constants'! |
1 | 183 |
|
3004
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
184 |
genericSignal |
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
185 |
"return the generic signal - thats the parent of all signals |
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
186 |
in the system." |
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
187 |
|
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
188 |
^ GenericSignal |
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
189 |
|
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
190 |
"Created: 8.10.1997 / 11:46:28 / cg" |
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
191 |
"Modified: 8.10.1997 / 11:47:08 / cg" |
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
192 |
! |
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
193 |
|
1 | 194 |
noHandlerSignal |
44 | 195 |
"return the signal used to handle unhandled signals" |
196 |
||
1 | 197 |
^ NoHandlerSignal |
4438 | 198 |
! |
199 |
||
200 |
proceedErrorSignal |
|
201 |
"return the signal used to indicate that a handler tried to |
|
202 |
proceed a signal marked as nonproceedable. |
|
203 |
The parameter for the exception raised by this signal is |
|
204 |
the exception which tried to proceed." |
|
205 |
||
206 |
^ ProceedErrorSignal |
|
207 |
||
208 |
"Modified: / 27.2.1998 / 14:22:13 / stefan" |
|
209 |
"Created: / 27.2.1998 / 14:36:15 / stefan" |
|
210 |
! |
|
211 |
||
212 |
wrongProceedabilitySignal |
|
213 |
"return the signal used to indicate that a signaler wants |
|
214 |
to raise a nonproceedable signal proceedable. |
|
215 |
The parameter for the exception raised by this signal is |
|
216 |
the unproceedable signal." |
|
217 |
||
218 |
^ WrongProceedabilitySignal |
|
219 |
||
220 |
"Created: / 27.2.1998 / 14:24:19 / stefan" |
|
4502 | 221 |
"Modified: / 2.8.1999 / 12:15:21 / stefan" |
1 | 222 |
! ! |
223 |
||
622 | 224 |
!Signal methodsFor:'accessing'! |
1 | 225 |
|
622 | 226 |
errorString |
4438 | 227 |
"return the notifier string. |
228 |
If the notifier string starts with space, prepend |
|
229 |
the parents notifier string" |
|
230 |
||
231 |
notifierString isNil ifTrue:[ |
|
232 |
^ parent errorString |
|
233 |
] ifFalse:[ |
|
234 |
(notifierString size > 0 |
|
235 |
and:[notifierString first == (Character space)]) ifTrue:[ |
|
236 |
^ parent errorString, notifierString |
|
237 |
] ifFalse:[ |
|
238 |
^ notifierString |
|
239 |
]. |
|
240 |
] |
|
241 |
||
242 |
" |
|
243 |
Object errorSignal errorString |
|
244 |
" |
|
245 |
||
246 |
"Modified: / 12.3.1998 / 15:04:41 / stefan" |
|
247 |
! |
|
248 |
||
249 |
errorStringExtra:extraString with:aParameter |
|
250 |
"used when raising with a given error string and/or parameter; |
|
251 |
if the errorString starts with a space, it is appended to the receivers |
|
252 |
notifier string; if it ends with a space, it is prepended. |
|
253 |
Otherwise, the extraString is returned. |
|
254 |
If no extraString is given, use the signals default errorString." |
|
255 |
||
256 |
|t| |
|
1 | 257 |
|
4438 | 258 |
(self inheritsFrom:Object userNotificationSignal) ifTrue:[ |
259 |
"/ all userNotifications pass the extraString unchanged. |
|
260 |
^ extraString |
|
261 |
]. |
|
262 |
||
263 |
extraString isNil ifTrue:[ |
|
264 |
t := self errorString |
|
265 |
] ifFalse:[ |
|
266 |
t := extraString. |
|
267 |
(extraString endsWith:Character space) ifTrue:[ |
|
268 |
t := extraString, self errorString |
|
269 |
] ifFalse:[ |
|
270 |
(extraString startsWith:Character space) ifTrue:[ |
|
271 |
t := self errorString, extraString |
|
272 |
] |
|
273 |
]. |
|
274 |
]. |
|
275 |
^ t. |
|
276 |
||
277 |
"/ aParameter isNil ifTrue:[ |
|
278 |
"/ ^ t |
|
279 |
"/ ]. |
|
280 |
"/ |
|
281 |
"/ (t startsWith:' ') ifTrue:[ |
|
282 |
"/ ^ aParameter printString , t |
|
283 |
"/ ]. |
|
284 |
"/ (t endsWith:' ') ifTrue:[ |
|
285 |
"/ ^ t , aParameter printString |
|
286 |
"/ ]. |
|
287 |
"/ ^ t |
|
288 |
||
289 |
"Modified: / 25.3.1997 / 12:12:37 / cg" |
|
290 |
"Created: / 12.3.1998 / 15:11:31 / stefan" |
|
622 | 291 |
! |
159 | 292 |
|
622 | 293 |
handlerBlock |
294 |
"return the handlerblock - if non-nil, this will be evaluated with the exception |
|
295 |
object as argument, if no #handle:do: context was found on the stack." |
|
296 |
||
297 |
^ handlerBlock |
|
1 | 298 |
! |
299 |
||
622 | 300 |
handlerBlock:aOneArgBlock |
301 |
"set the handlerblock - this will be evaluated with the exception |
|
302 |
object as argument, if no #handle:do: context was found on the stack." |
|
159 | 303 |
|
622 | 304 |
handlerBlock := aOneArgBlock |
305 |
! |
|
159 | 306 |
|
622 | 307 |
mayProceed |
308 |
"return the signals ability to proceed. |
|
309 |
This flag is (currently) not checked by the system; |
|
310 |
be prepared for changes here, to eventually have nonProceedable |
|
311 |
signals refuse to let you continue execution." |
|
1 | 312 |
|
622 | 313 |
^ mayProceed |
1 | 314 |
! |
315 |
||
316 |
mayProceed:aBoolean |
|
44 | 317 |
"set/clear the signals ability to proceed. |
419 | 318 |
This flag is (currently) not checked by the system; |
319 |
be prepared for changes here, to eventually have nonProceedable |
|
320 |
signals refuse to let you continue execution." |
|
1 | 321 |
|
322 |
mayProceed := aBoolean |
|
323 |
! |
|
324 |
||
622 | 325 |
nameClass:aClass message:aSelector |
326 |
"this sets the class & selector of a method which returns |
|
327 |
that signal - this is simply for documentation purposes - |
|
328 |
see Signal>>printOn: implementation. |
|
329 |
(took me a while to find that one out ;-)" |
|
419 | 330 |
|
622 | 331 |
nameClass := aClass. |
332 |
message := aSelector |
|
419 | 333 |
! |
334 |
||
622 | 335 |
notifierString |
336 |
"return the notifier string" |
|
159 | 337 |
|
622 | 338 |
^ notifierString |
339 |
! |
|
340 |
||
341 |
notifierString:aString |
|
342 |
"set the notifier string" |
|
343 |
||
344 |
notifierString := aString |
|
159 | 345 |
! |
346 |
||
347 |
parent |
|
348 |
"return the parent-signal of the receiver" |
|
349 |
||
350 |
^ parent |
|
351 |
! |
|
352 |
||
622 | 353 |
parent:aSignal |
354 |
"set the parent-signal of the receiver." |
|
355 |
||
356 |
parent := aSignal |
|
3004
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
357 |
! |
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
358 |
|
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
359 |
parent:aSignal mayProceed:aBoolean |
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
360 |
"set the parent-signal and the mayProceed flag of the receiver." |
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
361 |
|
3010 | 362 |
parent := aSignal. |
363 |
mayProceed := aBoolean. |
|
3004
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
364 |
|
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
365 |
"Modified: 8.10.1997 / 11:56:11 / cg" |
622 | 366 |
! ! |
367 |
||
368 |
!Signal methodsFor:'copying'! |
|
369 |
||
3348
37b0481be091
must catch #deppCopyUsing: instead of #deepCopy.
Claus Gittinger <cg@exept.de>
parents:
3280
diff
changeset
|
370 |
deepCopyUsing:aDictionary |
622 | 371 |
"raise an error - deepCopy is not allowed for signals" |
1 | 372 |
|
622 | 373 |
^ self deepCopyError |
3348
37b0481be091
must catch #deppCopyUsing: instead of #deepCopy.
Claus Gittinger <cg@exept.de>
parents:
3280
diff
changeset
|
374 |
|
37b0481be091
must catch #deppCopyUsing: instead of #deepCopy.
Claus Gittinger <cg@exept.de>
parents:
3280
diff
changeset
|
375 |
"Created: / 31.3.1998 / 15:43:01 / cg" |
622 | 376 |
! ! |
377 |
||
378 |
!Signal methodsFor:'instance creation'! |
|
1 | 379 |
|
622 | 380 |
newSignal |
381 |
"create a new signal, using the receiver as a prototype and |
|
382 |
setting the parent of the new signal to the receiver." |
|
1 | 383 |
|
3010 | 384 |
^ (self copy) parent:self |
3004
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
385 |
|
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
386 |
"Modified: 8.10.1997 / 11:53:06 / cg" |
70 | 387 |
! |
388 |
||
622 | 389 |
newSignalMayProceed:aBoolean |
390 |
"create a new signal, using the receiver as a prototype and |
|
391 |
setting the parent of the new signal to the receiver." |
|
362 | 392 |
|
3010 | 393 |
^ (self copy) parent:self mayProceed:aBoolean |
70 | 394 |
|
3004
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
395 |
"Modified: 8.10.1997 / 11:57:13 / cg" |
1 | 396 |
! ! |
397 |
||
159 | 398 |
!Signal methodsFor:'printing'! |
399 |
||
400 |
printOn:aStream |
|
401 |
"append a printed representation of the receiver on aStream" |
|
402 |
||
403 |
nameClass notNil ifTrue:[ |
|
4502 | 404 |
aStream nextPutAll:nameClass name. |
405 |
aStream space. |
|
406 |
aStream nextPutAll:message. |
|
407 |
^ self |
|
159 | 408 |
]. |
409 |
^ super printOn:aStream |
|
410 |
! ! |
|
411 |
||
622 | 412 |
!Signal methodsFor:'queries'! |
413 |
||
414 |
accepts:aSignal |
|
415 |
"return true, if the receiver accepts the argument, aSignal. |
|
416 |
(i.e. the receiver is aSignal or a parent of it). False otherwise." |
|
417 |
||
418 |
|s| |
|
419 |
||
420 |
aSignal isQuerySignal ifTrue:[^ false]. |
|
421 |
||
422 |
s := aSignal. |
|
423 |
[s notNil] whileTrue:[ |
|
4438 | 424 |
self == s ifTrue:[^ true]. |
425 |
s := s parent |
|
622 | 426 |
]. |
427 |
^ false |
|
4438 | 428 |
|
429 |
"Modified: / 22.3.1999 / 12:45:42 / stefan" |
|
622 | 430 |
! |
431 |
||
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
432 |
handlerForSignal:signal context:theContext originator:originator |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
433 |
"answer the handler block for the signal from originator. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
434 |
The block is retrieved from aContext. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
435 |
Answer nil if the signal is not handled" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
436 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
437 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
438 |
(theContext selector ~~ #'handle:from:do:' |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
439 |
or:[(theContext argAt:2) == originator]) ifTrue:[ |
4513 | 440 |
(self == signal or:[self accepts:signal]) ifTrue:[ |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
441 |
^ theContext argAt:1 |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
442 |
] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
443 |
]. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
444 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
445 |
^ nil |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
446 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
447 |
"Created: / 25.7.1999 / 19:55:43 / stefan" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
448 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
449 |
|
4476 | 450 |
handlingExceptionInContext:theContext |
4473
793078981f01
added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
451 |
"answer the handling signal from aContext." |
793078981f01
added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
452 |
|
793078981f01
added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
453 |
^ self |
793078981f01
added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
454 |
! |
793078981f01
added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
455 |
|
622 | 456 |
inheritsFrom:anotherSignal |
457 |
"return true, if the receiver is a child of anotherSignal |
|
458 |
(i.e. if handling anotherSignal also handles the receiver) |
|
459 |
This is almost the same as accepts, but returns false, if |
|
460 |
the receiver is identical to anotherSignal." |
|
461 |
||
462 |
self == anotherSignal ifTrue:[^ false]. |
|
463 |
^ anotherSignal accepts:self |
|
3521
4d83701cfc28
care for nil receiver in #isHandledIn:
Claus Gittinger <cg@exept.de>
parents:
3348
diff
changeset
|
464 |
|
4d83701cfc28
care for nil receiver in #isHandledIn:
Claus Gittinger <cg@exept.de>
parents:
3348
diff
changeset
|
465 |
"Modified: / 6.6.1998 / 20:37:47 / cg" |
622 | 466 |
! |
467 |
||
468 |
isHandled |
|
469 |
"return true, if there is a handler for the receiver signal. |
|
470 |
Raising an unhandled signal will usually lead into the debugger, |
|
2689 | 471 |
but can be caught globally by setting Exceptions EmergencyHandler." |
622 | 472 |
|
473 |
^ self isHandledIn:(thisContext sender). |
|
474 |
! |
|
475 |
||
476 |
isHandledIn:aContext |
|
477 |
"return true, if there is a handler for the receiver signal in the |
|
478 |
contextChain starting with aContext." |
|
479 |
||
3521
4d83701cfc28
care for nil receiver in #isHandledIn:
Claus Gittinger <cg@exept.de>
parents:
3348
diff
changeset
|
480 |
|con r| |
622 | 481 |
|
4493 | 482 |
con := Context findFirstSpecialHandle:true raise:false. |
622 | 483 |
[con notNil] whileTrue:[ |
4493 | 484 |
((r := con receiver) notNil |
485 |
and:[(r handlerForSignal:self context:con originator:nil) notNil] |
|
486 |
) ifTrue:[ |
|
487 |
"found a handler context" |
|
488 |
^ true |
|
489 |
]. |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
490 |
con := con findSpecialHandle:true raise:false. |
622 | 491 |
]. |
492 |
^ false |
|
2207 | 493 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
494 |
"Created: / 23.7.1999 / 14:03:34 / stefan" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
495 |
"Modified: / 26.7.1999 / 15:24:34 / stefan" |
622 | 496 |
! |
497 |
||
498 |
isQuerySignal |
|
1249 | 499 |
"return true, if this is a querySignal - always return false here" |
500 |
||
622 | 501 |
^ false |
1249 | 502 |
|
503 |
"Modified: 22.4.1996 / 13:45:06 / cg" |
|
622 | 504 |
! |
505 |
||
506 |
isSignal |
|
507 |
"return true, if the receiver is some kind of signal; |
|
508 |
true returned here - the method is redefined from Object." |
|
509 |
||
510 |
^ true |
|
511 |
! ! |
|
512 |
||
513 |
!Signal methodsFor:'raising'! |
|
514 |
||
4438 | 515 |
newException |
516 |
"answer a new exception object for this signal. |
|
517 |
Subclasses may redefine this method" |
|
518 |
||
4440 | 519 |
^ Exception signal:self originator:nil |
4438 | 520 |
|
521 |
"Created: / 26.2.1998 / 19:53:56 / stefan" |
|
4440 | 522 |
"Modified: / 23.7.1999 / 13:41:00 / stefan" |
4438 | 523 |
! |
524 |
||
525 |
newExceptionFrom:originator |
|
526 |
"answer a new exception object for this signal. |
|
527 |
Set the originator. |
|
528 |
Subclasses may redefine this method" |
|
529 |
||
4440 | 530 |
^ Exception signal:self originator:originator |
4438 | 531 |
|
532 |
"Created: / 27.2.1998 / 09:17:00 / stefan" |
|
4440 | 533 |
"Modified: / 23.7.1999 / 13:41:15 / stefan" |
4438 | 534 |
! |
535 |
||
622 | 536 |
raise |
4438 | 537 |
"raise a signal nonproceedable. |
622 | 538 |
The signals notifierString is used as errorString." |
539 |
||
4438 | 540 |
^ self newException raise |
1326 | 541 |
|
4438 | 542 |
"Modified: / 2.5.1996 / 16:36:23 / cg" |
543 |
"Modified: / 5.3.1998 / 16:44:36 / stefan" |
|
622 | 544 |
! |
545 |
||
546 |
raiseErrorString:aString |
|
1326 | 547 |
"raise a signal nonproceedable. |
622 | 548 |
The argument is used as errorString." |
549 |
||
4438 | 550 |
^ (self newException errorString:aString) raise. |
1326 | 551 |
|
4438 | 552 |
"Modified: / 9.5.1996 / 15:17:59 / cg" |
553 |
"Modified: / 12.3.1998 / 15:15:22 / stefan" |
|
622 | 554 |
! |
555 |
||
1610 | 556 |
raiseErrorString:aString in:aContext |
557 |
"raise a signal nonproceedable. |
|
558 |
The argument is used as errorString. |
|
559 |
The additional context is passed as the context responsible for the raise, |
|
560 |
allowing a raise to mimicri the exception happened somewhere else." |
|
561 |
||
4438 | 562 |
^ (self newException |
563 |
signal:self |
|
564 |
parameter:nil |
|
565 |
errorString:aString |
|
566 |
suspendedContext:aContext |
|
567 |
originator:nil) raise. |
|
1610 | 568 |
|
4438 | 569 |
"Created: / 26.7.1996 / 16:42:32 / cg" |
570 |
"Modified: / 26.7.1996 / 16:42:47 / cg" |
|
571 |
"Modified: / 12.3.1998 / 15:43:43 / stefan" |
|
1610 | 572 |
! |
573 |
||
622 | 574 |
raiseFrom:something |
1326 | 575 |
"raise a signal nonproceedable. |
4438 | 576 |
The argument, something is passed both as parameter and originator." |
622 | 577 |
|
4438 | 578 |
^ ((self newExceptionFrom:something) parameter:something) raise |
1326 | 579 |
|
4438 | 580 |
"Modified: / 2.5.1996 / 16:36:38 / cg" |
581 |
"Modified: / 5.3.1998 / 16:49:55 / stefan" |
|
622 | 582 |
! |
583 |
||
584 |
raiseIn:aContext |
|
1326 | 585 |
"raise a signal nonproceedable. |
622 | 586 |
The signals notifierString is used as errorString. |
587 |
The additional context is passed as the context responsible for the raise, |
|
588 |
allowing a raise to mimicri the exception happened somewhere else." |
|
589 |
||
4438 | 590 |
^ (self newException suspendedContext:aContext) raise. |
1326 | 591 |
|
4438 | 592 |
"Modified: / 2.5.1996 / 16:36:44 / cg" |
593 |
"Modified: / 5.3.1998 / 16:50:21 / stefan" |
|
622 | 594 |
! |
595 |
||
596 |
raiseRequest |
|
1326 | 597 |
"raise a signal proceedable. |
622 | 598 |
The signals notifierString is used as errorString." |
599 |
||
4438 | 600 |
^ self newException raiseRequest. |
1326 | 601 |
|
4438 | 602 |
"Modified: / 2.5.1996 / 16:36:52 / cg" |
603 |
"Modified: / 5.3.1998 / 16:50:46 / stefan" |
|
622 | 604 |
! |
605 |
||
3103 | 606 |
raiseRequestFrom:something |
607 |
"raise a signal proceedable. |
|
4438 | 608 |
The argument, something is passed both as parameter and originator." |
3103 | 609 |
|
4438 | 610 |
^ ((self newExceptionFrom:something) parameter:something) raiseRequest. |
3103 | 611 |
|
4438 | 612 |
"Modified: / 2.5.1996 / 16:36:38 / cg" |
613 |
"Modified: / 5.3.1998 / 16:52:46 / stefan" |
|
3103 | 614 |
! |
615 |
||
622 | 616 |
raiseRequestWith:aParameter |
1326 | 617 |
"raise a signal proceedable. |
622 | 618 |
The signals notifierString is used as errorString." |
619 |
||
4438 | 620 |
^ (self newException parameter:aParameter) raiseRequest. |
1326 | 621 |
|
4438 | 622 |
"Modified: / 9.5.1996 / 15:13:20 / cg" |
623 |
"Modified: / 12.3.1998 / 15:16:57 / stefan" |
|
622 | 624 |
! |
625 |
||
626 |
raiseRequestWith:aParameter errorString:aString |
|
1326 | 627 |
"raise a signal proceedable. |
622 | 628 |
The argument, aString is used as errorString." |
629 |
||
4438 | 630 |
^ (self newException |
631 |
parameter:aParameter; |
|
632 |
errorString:aString |
|
633 |
) raiseRequest |
|
1326 | 634 |
|
4438 | 635 |
"Modified: / 9.5.1996 / 15:13:35 / cg" |
636 |
"Modified: / 12.3.1998 / 15:17:52 / stefan" |
|
622 | 637 |
! |
638 |
||
639 |
raiseRequestWith:aParameter errorString:aString in:aContext |
|
1326 | 640 |
"raise a signal proceedable. |
622 | 641 |
The argument, aString is used as errorString. |
1608 | 642 |
The additional context is passed as the context responsible for the raise, |
643 |
allowing a raise to mimicri the exception happened somewhere else." |
|
622 | 644 |
|
4438 | 645 |
^ (self newException |
646 |
parameter:aParameter; |
|
647 |
errorString:aString; |
|
648 |
suspendedContext:aContext) raiseRequest |
|
1326 | 649 |
|
4438 | 650 |
"Modified: / 26.7.1996 / 16:29:27 / cg" |
651 |
"Modified: / 12.3.1998 / 15:18:34 / stefan" |
|
622 | 652 |
! |
653 |
||
654 |
raiseRequestWith:aParameter in:aContext |
|
1326 | 655 |
"raise a signal proceedable. |
622 | 656 |
The signals notifierString is used as errorString. |
1608 | 657 |
The additional context is passed as the context responsible for the raise, |
658 |
allowing a raise to mimicri the exception happened somewhere else." |
|
622 | 659 |
|
4438 | 660 |
^ (self newException |
661 |
parameter:aParameter; |
|
662 |
suspendedContext:aContext) raiseRequest. |
|
1326 | 663 |
|
4438 | 664 |
"Modified: / 26.7.1996 / 16:29:33 / cg" |
665 |
"Modified: / 12.3.1998 / 15:18:55 / stefan" |
|
622 | 666 |
! |
667 |
||
668 |
raiseWith:aParameter |
|
1326 | 669 |
"raise a signal nonproceedable. |
4438 | 670 |
The argument, aParameter is passed as parameter." |
622 | 671 |
|
4438 | 672 |
^ (self newException parameter:aParameter) raise. |
1326 | 673 |
|
4438 | 674 |
"Modified: / 9.5.1996 / 15:14:24 / cg" |
675 |
"Modified: / 12.3.1998 / 15:19:11 / stefan" |
|
622 | 676 |
! |
677 |
||
678 |
raiseWith:aParameter errorString:aString |
|
4438 | 679 |
"raise a signal nonproceedable. |
622 | 680 |
The argument, aString is used as errorString, aParameter is passed |
681 |
as exception parameter." |
|
682 |
||
4438 | 683 |
^ (self newException |
684 |
parameter:aParameter; |
|
685 |
errorString:aString) raise. |
|
1326 | 686 |
|
4438 | 687 |
"Modified: / 9.5.1996 / 15:14:32 / cg" |
688 |
"Modified: / 12.3.1998 / 15:19:40 / stefan" |
|
1326 | 689 |
! |
690 |
||
691 |
raiseWith:aParameter errorString:aString in:aContext |
|
4438 | 692 |
"raise a signal nonproceedable. |
1326 | 693 |
The argument, aString is used as errorString, aParameter is passed |
1608 | 694 |
as exception parameter. |
695 |
The additional context is passed as the context responsible for the raise, |
|
696 |
allowing a raise to mimicri the exception happened somewhere else." |
|
697 |
||
1326 | 698 |
|
4438 | 699 |
^ (self newException |
700 |
parameter:aParameter; |
|
701 |
errorString:aString; |
|
702 |
suspendedContext:aContext) raise. |
|
1326 | 703 |
|
4438 | 704 |
"Created: / 2.5.1996 / 16:37:25 / cg" |
705 |
"Modified: / 26.7.1996 / 16:29:42 / cg" |
|
706 |
"Modified: / 12.3.1998 / 15:20:12 / stefan" |
|
3157 | 707 |
! |
708 |
||
709 |
raiseWith:aParameter in:aContext |
|
710 |
"raise a signal nonproceedable. |
|
4438 | 711 |
The argument, aParameter is passed as parameter." |
3157 | 712 |
|
4438 | 713 |
^ (self newException parameter:aParameter; |
714 |
suspendedContext:aContext) raise. |
|
3157 | 715 |
|
716 |
"Modified: / 9.5.1996 / 15:14:24 / cg" |
|
717 |
"Created: / 4.1.1998 / 14:38:15 / cg" |
|
4438 | 718 |
"Modified: / 12.3.1998 / 15:34:51 / stefan" |
622 | 719 |
! ! |
720 |
||
1 | 721 |
!Signal methodsFor:'save evaluation'! |
722 |
||
622 | 723 |
catch:aBlock |
724 |
"evaluate the argument, aBlock. |
|
725 |
If the receiver-signal is raised during evaluation, abort |
|
726 |
the evaluation and return true; otherwise return false. |
|
727 |
This is the catch & throw mechanism found in other languages, |
|
728 |
where the returned value indicates if an exception occured." |
|
729 |
||
730 |
|raiseOccurred| |
|
731 |
||
732 |
raiseOccurred := false. |
|
733 |
self handle:[:ex | raiseOccurred := true. ex return] do:aBlock. |
|
734 |
^ raiseOccurred |
|
735 |
||
736 |
" |
|
737 |
Object messageNotUnderstoodSignal catch:[ |
|
4502 | 738 |
123 size open |
622 | 739 |
] |
740 |
" |
|
741 |
! |
|
742 |
||
1 | 743 |
handle:handleBlock do:aBlock |
744 |
"evaluate the argument, aBlock. |
|
745 |
If the receiver-signal is raised during evaluation, |
|
746 |
evaluate the handleBlock passing it an Exception argument. |
|
747 |
The handler may decide how to react to the signal by sending |
|
748 |
a corresponding message to the exception (see there). |
|
749 |
If the signal is not raised, return the value of evaluating |
|
750 |
aBlock." |
|
751 |
||
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
752 |
<exception: #handle> |
95 | 753 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
754 |
"/ thisContext markForHandle. -- same as above pragma |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
755 |
^ aBlock value "the real logic is in Exception>>doRaise" |
120 | 756 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
757 |
" |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
758 |
Object messageNotUnderstoodSignal handle:[:ex | |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
759 |
'oops' printNL. |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
760 |
ex return |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
761 |
] do:[ |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
762 |
123 size open |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
763 |
] |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
764 |
" |
95 | 765 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
766 |
" |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
767 |
|num| |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
768 |
|
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
769 |
num := 0. |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
770 |
Number divisionByZeroSignal handle:[:ex | |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
771 |
'oops' printNL. |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
772 |
ex return |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
773 |
] do:[ |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
774 |
123 / num |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
775 |
] |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
776 |
" |
4438 | 777 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
778 |
"Modified: / 25.7.1999 / 19:43:01 / stefan" |
44 | 779 |
! |
780 |
||
362 | 781 |
handle:handleBlock from:anObject do:aBlock |
782 |
"evaluate the argument, aBlock. |
|
783 |
If the receiver-signal is raised during evaluation, |
|
784 |
and the exception originated from anObject, |
|
785 |
evaluate the handleBlock passing it an Exception argument. |
|
786 |
The handler may decide how to react to the signal by sending |
|
787 |
a corresponding message to the exception (see there). |
|
788 |
If the signal is not raised, return the value of evaluating |
|
789 |
aBlock." |
|
790 |
||
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
791 |
<exception: #handle> |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
792 |
|
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
793 |
"/ thisContext markForHandle. -- same as above pragma |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
794 |
^ aBlock value "the real logic is in Exception>>doRaise" |
362 | 795 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
796 |
" |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
797 |
the first open will be caught; the second not: |
362 | 798 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
799 |
|o1 o2| |
362 | 800 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
801 |
o1 := 123. |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
802 |
o2 := nil. |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
803 |
Object messageNotUnderstoodSignal |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
804 |
handle: |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
805 |
[:ex | |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
806 |
'oops' printNL. |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
807 |
ex proceed |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
808 |
] |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
809 |
from:o1 |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
810 |
do: |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
811 |
[ |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
812 |
o1 open. |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
813 |
o2 open |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
814 |
] |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
815 |
" |
4438 | 816 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
817 |
"Modified: / 25.7.1999 / 19:43:40 / stefan" |
362 | 818 |
! |
819 |
||
419 | 820 |
ignoreIn:aBlock |
159 | 821 |
"evaluate the argument, aBlock. |
822 |
Ignore the receiver-signal during evaluation - i.e. simply |
|
419 | 823 |
continue. |
824 |
This makes only sense for some signals, such as UserInterrupt |
|
825 |
or AbortSignal, because continuing after an exception without any cleanup |
|
826 |
often leads to followup-errors." |
|
159 | 827 |
|
4486
f84def7aaf3f
replaced #proceed with #proceedWith:nil
Claus Gittinger <cg@exept.de>
parents:
4476
diff
changeset
|
828 |
^ self handle:[:ex | ex proceedWith:nil] do:aBlock. |
159 | 829 |
|
830 |
" |
|
419 | 831 |
Object messageNotUnderstoodSignal ignoreIn:[ |
4486
f84def7aaf3f
replaced #proceed with #proceedWith:nil
Claus Gittinger <cg@exept.de>
parents:
4476
diff
changeset
|
832 |
123 size open |
61 | 833 |
] |
834 |
" |
|
1 | 835 |
! ! |
836 |
||
2207 | 837 |
!Signal class methodsFor:'documentation'! |
1249 | 838 |
|
839 |
version |
|
4513 | 840 |
^ '$Header: /cvs/stx/stx/libbasic/Signal.st,v 1.63 1999-08-03 12:52:45 cg Exp $' |
1249 | 841 |
! ! |
622 | 842 |
Signal initialize! |