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