author | Stefan Vogel <sv@exept.de> |
Wed, 29 Oct 2003 13:07:45 +0100 | |
changeset 7722 | 06603eb0d219 |
parent 7261 | f35fc9cee675 |
child 8239 | 23e8064adc69 |
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 |
||
315 |
, anException |
|
316 |
"return a SignalSet with myself and anException" |
|
317 |
||
318 |
^ SignalSet with:self with:anException |
|
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:[ |
361 |
^ parent errorString |
|
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 |
" |
|
5949 | 370 |
Object errorSignal description |
4563 | 371 |
" |
372 |
||
373 |
"Modified: / 12.3.1998 / 15:04:41 / stefan" |
|
6116 | 374 |
|
4563 | 375 |
! |
376 |
||
159 | 377 |
printOn:aStream |
378 |
"append a printed representation of the receiver on aStream" |
|
379 |
||
380 |
nameClass notNil ifTrue:[ |
|
4622
905b21c17057
care for non-class nameClass in printOn:
Claus Gittinger <cg@exept.de>
parents:
4564
diff
changeset
|
381 |
nameClass isBehavior ifTrue:[ |
905b21c17057
care for non-class nameClass in printOn:
Claus Gittinger <cg@exept.de>
parents:
4564
diff
changeset
|
382 |
aStream nextPutAll:nameClass name. |
905b21c17057
care for non-class nameClass in printOn:
Claus Gittinger <cg@exept.de>
parents:
4564
diff
changeset
|
383 |
] ifFalse:[ |
905b21c17057
care for non-class nameClass in printOn:
Claus Gittinger <cg@exept.de>
parents:
4564
diff
changeset
|
384 |
nameClass printOn:aStream. |
905b21c17057
care for non-class nameClass in printOn:
Claus Gittinger <cg@exept.de>
parents:
4564
diff
changeset
|
385 |
]. |
4502 | 386 |
aStream space. |
387 |
aStream nextPutAll:message. |
|
388 |
^ self |
|
159 | 389 |
]. |
390 |
^ super printOn:aStream |
|
391 |
! ! |
|
392 |
||
622 | 393 |
!Signal methodsFor:'queries'! |
394 |
||
395 |
accepts:aSignal |
|
396 |
"return true, if the receiver accepts the argument, aSignal. |
|
397 |
(i.e. the receiver is aSignal or a parent of it). False otherwise." |
|
398 |
||
399 |
|s| |
|
400 |
||
4527 | 401 |
self == aSignal ifTrue:[^ true]. |
622 | 402 |
aSignal isQuerySignal ifTrue:[^ false]. |
403 |
||
404 |
s := aSignal. |
|
405 |
[s notNil] whileTrue:[ |
|
4438 | 406 |
self == s ifTrue:[^ true]. |
407 |
s := s parent |
|
622 | 408 |
]. |
409 |
^ false |
|
4438 | 410 |
|
411 |
"Modified: / 22.3.1999 / 12:45:42 / stefan" |
|
622 | 412 |
! |
413 |
||
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
414 |
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
|
415 |
"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
|
416 |
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
|
417 |
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
|
418 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
419 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
420 |
(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
|
421 |
or:[(theContext argAt:2) == originator]) ifTrue:[ |
4513 | 422 |
(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
|
423 |
^ theContext argAt:1 |
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 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
427 |
^ nil |
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 |
"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
|
430 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
431 |
|
4547
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
432 |
handlerProtectedBlock:doBlock inContext:context |
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
433 |
"set the handlerProtectedBlock in context" |
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
434 |
|
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
435 |
context selector == #handle:do: ifTrue:[ |
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
436 |
context argAt:2 put:doBlock. |
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
437 |
] ifFalse:[context selector == #handle:from:do: ifTrue:[ |
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
438 |
context argAt:3 put:doBlock. |
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 |
! |
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
444 |
|
4476 | 445 |
handlingExceptionInContext:theContext |
4473
793078981f01
added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
446 |
"answer the handling signal from aContext." |
793078981f01
added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
447 |
|
793078981f01
added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
448 |
^ self |
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 |
|
622 | 451 |
inheritsFrom:anotherSignal |
452 |
"return true, if the receiver is a child of anotherSignal |
|
453 |
(i.e. if handling anotherSignal also handles the receiver) |
|
454 |
This is almost the same as accepts, but returns false, if |
|
455 |
the receiver is identical to anotherSignal." |
|
456 |
||
457 |
self == anotherSignal ifTrue:[^ false]. |
|
458 |
^ anotherSignal accepts:self |
|
3521
4d83701cfc28
care for nil receiver in #isHandledIn:
Claus Gittinger <cg@exept.de>
parents:
3348
diff
changeset
|
459 |
|
4d83701cfc28
care for nil receiver in #isHandledIn:
Claus Gittinger <cg@exept.de>
parents:
3348
diff
changeset
|
460 |
"Modified: / 6.6.1998 / 20:37:47 / cg" |
622 | 461 |
! |
462 |
||
6200 | 463 |
isControlInterrupt |
464 |
^ false |
|
465 |
||
466 |
"Created: / 16.11.2001 / 16:12:20 / cg" |
|
467 |
! |
|
468 |
||
6631
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
469 |
isExceptionCreator |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
470 |
"return true, if the receiver can create exceptions, |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
471 |
this includes #raise, #raiseRequest as well as the behavior of |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
472 |
an exception handler, such as the #accepts: and #handles: messages" |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
473 |
|
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
474 |
^ true |
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 |
|
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
477 |
isExceptionHandler |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
478 |
"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
|
479 |
especially to the #accepts: and #handles: messages" |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
480 |
|
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
481 |
^ true |
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 |
|
622 | 484 |
isHandled |
485 |
"return true, if there is a handler for the receiver signal. |
|
486 |
Raising an unhandled signal will usually lead into the debugger, |
|
2689 | 487 |
but can be caught globally by setting Exceptions EmergencyHandler." |
622 | 488 |
|
4676 | 489 |
^ GenericException exception:self isHandledIn:(thisContext sender). |
622 | 490 |
! |
491 |
||
492 |
isHandledIn:aContext |
|
493 |
"return true, if there is a handler for the receiver signal in the |
|
494 |
contextChain starting with aContext." |
|
495 |
||
4676 | 496 |
^ GenericException exception:self isHandledIn:aContext |
622 | 497 |
! |
498 |
||
499 |
isQuerySignal |
|
1249 | 500 |
"return true, if this is a querySignal - always return false here" |
501 |
||
622 | 502 |
^ false |
1249 | 503 |
|
504 |
"Modified: 22.4.1996 / 13:45:06 / cg" |
|
622 | 505 |
! ! |
506 |
||
507 |
!Signal methodsFor:'raising'! |
|
508 |
||
4438 | 509 |
newException |
510 |
"answer a new exception object for this signal. |
|
511 |
Subclasses may redefine this method" |
|
512 |
||
4440 | 513 |
^ Exception signal:self originator:nil |
4438 | 514 |
|
515 |
"Created: / 26.2.1998 / 19:53:56 / stefan" |
|
4440 | 516 |
"Modified: / 23.7.1999 / 13:41:00 / stefan" |
4438 | 517 |
! |
518 |
||
519 |
newExceptionFrom:originator |
|
520 |
"answer a new exception object for this signal. |
|
521 |
Set the originator. |
|
522 |
Subclasses may redefine this method" |
|
523 |
||
4440 | 524 |
^ Exception signal:self originator:originator |
4438 | 525 |
|
526 |
"Created: / 27.2.1998 / 09:17:00 / stefan" |
|
4440 | 527 |
"Modified: / 23.7.1999 / 13:41:15 / stefan" |
4438 | 528 |
! |
529 |
||
622 | 530 |
raise |
4438 | 531 |
"raise a signal nonproceedable. |
622 | 532 |
The signals notifierString is used as errorString." |
533 |
||
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
534 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
535 |
|
4540
4b99a82fe85a
suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents:
4527
diff
changeset
|
536 |
^ self newException |
4b99a82fe85a
suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents:
4527
diff
changeset
|
537 |
suspendedContext:thisContext sender; |
4b99a82fe85a
suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents:
4527
diff
changeset
|
538 |
raise |
1326 | 539 |
|
4438 | 540 |
"Modified: / 2.5.1996 / 16:36:23 / cg" |
541 |
"Modified: / 5.3.1998 / 16:44:36 / stefan" |
|
622 | 542 |
! |
543 |
||
544 |
raiseErrorString:aString |
|
1326 | 545 |
"raise a signal nonproceedable. |
622 | 546 |
The argument is used as errorString." |
547 |
||
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
548 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
549 |
|
4540
4b99a82fe85a
suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents:
4527
diff
changeset
|
550 |
^ self newException |
4b99a82fe85a
suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents:
4527
diff
changeset
|
551 |
suspendedContext:thisContext sender; |
7722
06603eb0d219
do not use obsolete message #errorString:
Stefan Vogel <sv@exept.de>
parents:
7261
diff
changeset
|
552 |
messageText:aString; |
4540
4b99a82fe85a
suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents:
4527
diff
changeset
|
553 |
raise. |
1326 | 554 |
|
4438 | 555 |
"Modified: / 9.5.1996 / 15:17:59 / cg" |
556 |
"Modified: / 12.3.1998 / 15:15:22 / stefan" |
|
622 | 557 |
! |
558 |
||
5685 | 559 |
raiseErrorString:aString in:aContext |
560 |
"raise a signal nonproceedable. |
|
561 |
The argument is used as errorString." |
|
562 |
||
563 |
<context: #return> |
|
564 |
||
565 |
^ self newException |
|
566 |
suspendedContext:aContext; |
|
7722
06603eb0d219
do not use obsolete message #errorString:
Stefan Vogel <sv@exept.de>
parents:
7261
diff
changeset
|
567 |
messageText:aString; |
5685 | 568 |
raise. |
569 |
||
570 |
"Modified: / 9.5.1996 / 15:17:59 / cg" |
|
571 |
"Modified: / 12.3.1998 / 15:15:22 / stefan" |
|
572 |
! |
|
573 |
||
622 | 574 |
raiseFrom:something |
1326 | 575 |
"raise a signal nonproceedable. |
4438 | 576 |
The argument, something is passed both as parameter and originator." |
622 | 577 |
|
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
578 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
579 |
|
4540
4b99a82fe85a
suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents:
4527
diff
changeset
|
580 |
^ (self newExceptionFrom:something) |
4b99a82fe85a
suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents:
4527
diff
changeset
|
581 |
suspendedContext:thisContext sender; |
4b99a82fe85a
suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents:
4527
diff
changeset
|
582 |
parameter:something; |
4b99a82fe85a
suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents:
4527
diff
changeset
|
583 |
raise |
1326 | 584 |
|
4438 | 585 |
"Modified: / 2.5.1996 / 16:36:38 / cg" |
586 |
"Modified: / 5.3.1998 / 16:49:55 / stefan" |
|
622 | 587 |
! |
588 |
||
589 |
raiseRequest |
|
1326 | 590 |
"raise a signal proceedable. |
622 | 591 |
The signals notifierString is used as errorString." |
592 |
||
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
593 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
594 |
|
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
595 |
^ self newException |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
596 |
suspendedContext:thisContext sender; |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
597 |
raiseRequest. |
1326 | 598 |
|
4438 | 599 |
"Modified: / 2.5.1996 / 16:36:52 / cg" |
600 |
"Modified: / 5.3.1998 / 16:50:46 / stefan" |
|
622 | 601 |
! |
602 |
||
4759
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
603 |
raiseRequestErrorString:aString |
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
604 |
"raise a signal proceedable. |
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
605 |
The argument, aString is used as errorString." |
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
606 |
|
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
607 |
<context: #return> |
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 |
^ self newException |
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
610 |
suspendedContext:thisContext sender; |
7722
06603eb0d219
do not use obsolete message #errorString:
Stefan Vogel <sv@exept.de>
parents:
7261
diff
changeset
|
611 |
messageText:aString; |
4759
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
612 |
raiseRequest |
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
613 |
|
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
614 |
"Modified: / 9.5.1996 / 15:13:35 / cg" |
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
615 |
"Modified: / 12.3.1998 / 15:17:52 / stefan" |
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
616 |
! |
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
617 |
|
3103 | 618 |
raiseRequestFrom:something |
619 |
"raise a signal proceedable. |
|
4438 | 620 |
The argument, something is passed both as parameter and originator." |
3103 | 621 |
|
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
622 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
623 |
|
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
624 |
^ (self newExceptionFrom:something) |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
625 |
suspendedContext:thisContext sender; |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
626 |
parameter:something; |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
627 |
raiseRequest. |
3103 | 628 |
|
4438 | 629 |
"Modified: / 2.5.1996 / 16:36:38 / cg" |
630 |
"Modified: / 5.3.1998 / 16:52:46 / stefan" |
|
3103 | 631 |
! |
632 |
||
622 | 633 |
raiseRequestWith:aParameter |
1326 | 634 |
"raise a signal proceedable. |
622 | 635 |
The signals notifierString is used as errorString." |
636 |
||
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
637 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
638 |
|
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
639 |
^ self newException |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
640 |
suspendedContext:thisContext sender; |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
641 |
parameter:aParameter; |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
642 |
raiseRequest. |
1326 | 643 |
|
4438 | 644 |
"Modified: / 9.5.1996 / 15:13:20 / cg" |
645 |
"Modified: / 12.3.1998 / 15:16:57 / stefan" |
|
622 | 646 |
! |
647 |
||
648 |
raiseRequestWith:aParameter errorString:aString |
|
1326 | 649 |
"raise a signal proceedable. |
622 | 650 |
The argument, aString is used as errorString." |
651 |
||
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
652 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
653 |
|
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
654 |
^ self newException |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
655 |
suspendedContext:thisContext sender; |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
656 |
parameter:aParameter; |
7722
06603eb0d219
do not use obsolete message #errorString:
Stefan Vogel <sv@exept.de>
parents:
7261
diff
changeset
|
657 |
messageText:aString; |
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
658 |
raiseRequest |
1326 | 659 |
|
4438 | 660 |
"Modified: / 9.5.1996 / 15:13:35 / cg" |
661 |
"Modified: / 12.3.1998 / 15:17:52 / stefan" |
|
622 | 662 |
! |
663 |
||
664 |
raiseRequestWith:aParameter errorString:aString in:aContext |
|
1326 | 665 |
"raise a signal proceedable. |
622 | 666 |
The argument, aString is used as errorString. |
1608 | 667 |
The additional context is passed as the context responsible for the raise, |
668 |
allowing a raise to mimicri the exception happened somewhere else." |
|
622 | 669 |
|
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
670 |
^ self newException |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
671 |
parameter:aParameter; |
7722
06603eb0d219
do not use obsolete message #errorString:
Stefan Vogel <sv@exept.de>
parents:
7261
diff
changeset
|
672 |
messageText:aString; |
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
673 |
suspendedContext:aContext; |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
674 |
raiseRequest |
1326 | 675 |
|
4438 | 676 |
"Modified: / 26.7.1996 / 16:29:27 / cg" |
677 |
"Modified: / 12.3.1998 / 15:18:34 / stefan" |
|
622 | 678 |
! |
679 |
||
680 |
raiseWith:aParameter |
|
1326 | 681 |
"raise a signal nonproceedable. |
4438 | 682 |
The argument, aParameter is passed as parameter." |
622 | 683 |
|
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
684 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
685 |
|
4540
4b99a82fe85a
suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents:
4527
diff
changeset
|
686 |
^ self newException |
4b99a82fe85a
suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents:
4527
diff
changeset
|
687 |
suspendedContext:thisContext sender; |
4b99a82fe85a
suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents:
4527
diff
changeset
|
688 |
parameter:aParameter; |
4b99a82fe85a
suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents:
4527
diff
changeset
|
689 |
raise. |
1326 | 690 |
|
4438 | 691 |
"Modified: / 9.5.1996 / 15:14:24 / cg" |
692 |
"Modified: / 12.3.1998 / 15:19:11 / stefan" |
|
622 | 693 |
! |
694 |
||
695 |
raiseWith:aParameter errorString:aString |
|
4438 | 696 |
"raise a signal nonproceedable. |
622 | 697 |
The argument, aString is used as errorString, aParameter is passed |
698 |
as exception parameter." |
|
699 |
||
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
700 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
701 |
|
4540
4b99a82fe85a
suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents:
4527
diff
changeset
|
702 |
^ self newException |
4b99a82fe85a
suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents:
4527
diff
changeset
|
703 |
suspendedContext:thisContext sender; |
4b99a82fe85a
suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents:
4527
diff
changeset
|
704 |
parameter:aParameter; |
7722
06603eb0d219
do not use obsolete message #errorString:
Stefan Vogel <sv@exept.de>
parents:
7261
diff
changeset
|
705 |
messageText:aString; |
4540
4b99a82fe85a
suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents:
4527
diff
changeset
|
706 |
raise. |
1326 | 707 |
|
4438 | 708 |
"Modified: / 9.5.1996 / 15:14:32 / cg" |
709 |
"Modified: / 12.3.1998 / 15:19:40 / stefan" |
|
1326 | 710 |
! |
711 |
||
712 |
raiseWith:aParameter errorString:aString in:aContext |
|
4438 | 713 |
"raise a signal nonproceedable. |
1326 | 714 |
The argument, aString is used as errorString, aParameter is passed |
1608 | 715 |
as exception parameter. |
716 |
The additional context is passed as the context responsible for the raise, |
|
717 |
allowing a raise to mimicri the exception happened somewhere else." |
|
718 |
||
4540
4b99a82fe85a
suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents:
4527
diff
changeset
|
719 |
^ self newException |
4b99a82fe85a
suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents:
4527
diff
changeset
|
720 |
parameter:aParameter; |
7722
06603eb0d219
do not use obsolete message #errorString:
Stefan Vogel <sv@exept.de>
parents:
7261
diff
changeset
|
721 |
messageText:aString; |
4540
4b99a82fe85a
suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents:
4527
diff
changeset
|
722 |
suspendedContext:aContext; |
4b99a82fe85a
suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents:
4527
diff
changeset
|
723 |
raise. |
1326 | 724 |
|
4438 | 725 |
"Created: / 2.5.1996 / 16:37:25 / cg" |
726 |
"Modified: / 26.7.1996 / 16:29:42 / cg" |
|
727 |
"Modified: / 12.3.1998 / 15:20:12 / stefan" |
|
622 | 728 |
! ! |
729 |
||
1 | 730 |
!Signal methodsFor:'save evaluation'! |
731 |
||
622 | 732 |
catch:aBlock |
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
733 |
"evaluate the argument, aBlock. |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
734 |
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
|
735 |
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
|
736 |
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
|
737 |
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
|
738 |
|
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
739 |
|raiseOccurred| |
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 := false. |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
742 |
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
|
743 |
^ raiseOccurred |
622 | 744 |
|
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
745 |
" |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
746 |
Object messageNotUnderstoodSignal catch:[ |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
747 |
123 size open |
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 |
|
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
752 |
deferAfter:aBlock |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
753 |
"evaluate the argument, aBlock. |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
754 |
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
|
755 |
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
|
756 |
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
|
757 |
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
|
758 |
and only a single raise is performed after the blocks evaluation. |
622 | 759 |
|
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
760 |
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
|
761 |
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
|
762 |
(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
|
763 |
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
|
764 |
|
6429
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
765 |
|coughtException result| |
622 | 766 |
|
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
767 |
self handle:[:ex | |
6429
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
768 |
coughtException isNil ifTrue:[ |
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
769 |
coughtException := ex. |
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
770 |
]. |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
771 |
ex proceedWith:nil |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
772 |
] do:[ |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
773 |
result := aBlock value. |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
774 |
]. |
6429
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
775 |
coughtException notNil ifTrue:[ |
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
776 |
coughtException suspendedContext:thisContext. |
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
777 |
|
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
778 |
"/ the signal was raised during the execution of aBlock above. |
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
779 |
"/ Raise it now (delayed). |
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
780 |
coughtException raiseSignal |
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
781 |
]. |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
782 |
^ result |
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 |
" |
6429
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
785 |
|s| |
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
786 |
|
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
787 |
s := Signal new mayProceed:true. |
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
788 |
s deferAfter:[ |
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
789 |
s raiseRequestWith:'hello' errorString:'eeee' |
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
790 |
] |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
791 |
" |
622 | 792 |
! |
793 |
||
1 | 794 |
handle:handleBlock do:aBlock |
795 |
"evaluate the argument, aBlock. |
|
796 |
If the receiver-signal is raised during evaluation, |
|
797 |
evaluate the handleBlock passing it an Exception argument. |
|
798 |
The handler may decide how to react to the signal by sending |
|
799 |
a corresponding message to the exception (see there). |
|
800 |
If the signal is not raised, return the value of evaluating |
|
801 |
aBlock." |
|
802 |
||
4547
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
803 |
<context: #return> |
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
804 |
<exception: #handle> |
95 | 805 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
806 |
"/ thisContext markForHandle. -- same as above pragma |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
807 |
^ aBlock value "the real logic is in Exception>>doRaise" |
120 | 808 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
809 |
" |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
810 |
Object messageNotUnderstoodSignal handle:[:ex | |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
811 |
'oops' printNL. |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
812 |
ex return |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
813 |
] do:[ |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
814 |
123 size open |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
815 |
] |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
816 |
" |
95 | 817 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
818 |
" |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
819 |
|num| |
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 := 0. |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
822 |
Number divisionByZeroSignal handle:[:ex | |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
823 |
'oops' printNL. |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
824 |
ex return |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
825 |
] do:[ |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
826 |
123 / num |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
827 |
] |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
828 |
" |
4438 | 829 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
830 |
"Modified: / 25.7.1999 / 19:43:01 / stefan" |
44 | 831 |
! |
832 |
||
362 | 833 |
handle:handleBlock from:anObject do:aBlock |
834 |
"evaluate the argument, aBlock. |
|
835 |
If the receiver-signal is raised during evaluation, |
|
836 |
and the exception originated from anObject, |
|
837 |
evaluate the handleBlock passing it an Exception argument. |
|
838 |
The handler may decide how to react to the signal by sending |
|
839 |
a corresponding message to the exception (see there). |
|
840 |
If the signal is not raised, return the value of evaluating |
|
841 |
aBlock." |
|
842 |
||
4547
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
843 |
<context: #return> |
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
844 |
<exception: #handle> |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
845 |
|
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
846 |
"/ thisContext markForHandle. -- same as above pragma |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
847 |
^ aBlock value "the real logic is in Exception>>doRaise" |
362 | 848 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
849 |
" |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
850 |
the first open will be caught; the second not: |
362 | 851 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
852 |
|o1 o2| |
362 | 853 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
854 |
o1 := 123. |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
855 |
o2 := nil. |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
856 |
Object messageNotUnderstoodSignal |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
857 |
handle: |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
858 |
[:ex | |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
859 |
'oops' printNL. |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
860 |
ex proceed |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
861 |
] |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
862 |
from:o1 |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
863 |
do: |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
864 |
[ |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
865 |
o1 open. |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
866 |
o2 open |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
867 |
] |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
868 |
" |
4438 | 869 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
870 |
"Modified: / 25.7.1999 / 19:43:40 / stefan" |
362 | 871 |
! |
872 |
||
419 | 873 |
ignoreIn:aBlock |
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
874 |
"evaluate the argument, aBlock. |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
875 |
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
|
876 |
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
|
877 |
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
|
878 |
often leads to followup-errors." |
159 | 879 |
|
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
880 |
^ self handle:[:ex | ex proceedWith:nil] do:aBlock. |
159 | 881 |
|
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
882 |
" |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
883 |
Object messageNotUnderstoodSignal ignoreIn:[ |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
884 |
123 size open |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
885 |
] |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
886 |
" |
1 | 887 |
! ! |
888 |
||
2207 | 889 |
!Signal class methodsFor:'documentation'! |
1249 | 890 |
|
891 |
version |
|
7722
06603eb0d219
do not use obsolete message #errorString:
Stefan Vogel <sv@exept.de>
parents:
7261
diff
changeset
|
892 |
^ '$Header: /cvs/stx/stx/libbasic/Signal.st,v 1.92 2003-10-29 12:07:45 stefan Exp $' |
1249 | 893 |
! ! |