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