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