author | HG Automerge |
Wed, 30 Nov 2016 10:25:34 +0000 | |
branch | jv |
changeset 21088 | 6f4535127ce6 |
parent 21024 | 8734987eb5c7 |
parent 21046 | 4aca308b3427 |
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. |
20953 | 43 |
I.e. what used to be instances of Signal/QuerySignal is being |
20091 | 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 |
|
21046 | 323 |
|exception| |
324 |
||
325 |
parent notNil ifTrue:[ |
|
326 |
"parent may be a class based signal" |
|
327 |
exception := parent newException. |
|
328 |
] ifFalse:[ |
|
329 |
exception := Exception basicNew. |
|
330 |
]. |
|
331 |
||
332 |
^ exception creator:self |
|
8681
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
333 |
|
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
334 |
"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
|
335 |
"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
|
336 |
! ! |
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
337 |
|
622 | 338 |
!Signal methodsFor:'instance creation'! |
1 | 339 |
|
622 | 340 |
newSignal |
341 |
"create a new signal, using the receiver as a prototype and |
|
342 |
setting the parent of the new signal to the receiver." |
|
1 | 343 |
|
3010 | 344 |
^ (self copy) parent:self |
3004
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
345 |
|
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
346 |
"Modified: 8.10.1997 / 11:53:06 / cg" |
70 | 347 |
! |
348 |
||
622 | 349 |
newSignalMayProceed:aBoolean |
350 |
"create a new signal, using the receiver as a prototype and |
|
351 |
setting the parent of the new signal to the receiver." |
|
362 | 352 |
|
3010 | 353 |
^ (self copy) parent:self mayProceed:aBoolean |
70 | 354 |
|
3004
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
355 |
"Modified: 8.10.1997 / 11:57:13 / cg" |
1 | 356 |
! ! |
357 |
||
5570 | 358 |
!Signal methodsFor:'printing & storing'! |
159 | 359 |
|
4563 | 360 |
description |
361 |
"return the notifier string. |
|
362 |
If the notifier string starts with space, prepend |
|
363 |
the parents notifier string" |
|
364 |
||
6116 | 365 |
|s| |
366 |
||
4563 | 367 |
notifierString isNil ifTrue:[ |
16562 | 368 |
^ parent description |
5949 | 369 |
]. |
6116 | 370 |
s := notifierString asString. |
371 |
(s startsWith:Character space) ifTrue:[ |
|
16562 | 372 |
^ parent description, s |
5949 | 373 |
]. |
6116 | 374 |
^ s |
4563 | 375 |
|
376 |
" |
|
8292 | 377 |
Error description |
4563 | 378 |
" |
379 |
||
380 |
"Modified: / 12.3.1998 / 15:04:41 / stefan" |
|
381 |
! |
|
382 |
||
14961 | 383 |
descriptionForDebugger |
16562 | 384 |
"return the description string of the signal which is used in the |
14961 | 385 |
debugger title area" |
386 |
||
387 |
^ self description. |
|
388 |
! |
|
389 |
||
159 | 390 |
printOn:aStream |
391 |
"append a printed representation of the receiver on aStream" |
|
392 |
||
393 |
nameClass notNil ifTrue:[ |
|
16562 | 394 |
nameClass isBehavior ifTrue:[ |
395 |
aStream nextPutAll:nameClass name. |
|
396 |
] ifFalse:[ |
|
397 |
nameClass printOn:aStream. |
|
398 |
]. |
|
399 |
aStream space. |
|
400 |
aStream nextPutAll:message. |
|
401 |
^ self |
|
159 | 402 |
]. |
403 |
^ super printOn:aStream |
|
404 |
! ! |
|
405 |
||
622 | 406 |
!Signal methodsFor:'queries'! |
407 |
||
408 |
accepts:aSignal |
|
409 |
"return true, if the receiver accepts the argument, aSignal. |
|
410 |
(i.e. the receiver is aSignal or a parent of it). False otherwise." |
|
411 |
||
412 |
|s| |
|
413 |
||
4527 | 414 |
self == aSignal ifTrue:[^ true]. |
622 | 415 |
aSignal isQuerySignal ifTrue:[^ false]. |
416 |
||
8681
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
417 |
s := aSignal parent. |
622 | 418 |
[s notNil] whileTrue:[ |
16562 | 419 |
self == s ifTrue:[^ true]. |
420 |
s := s parent |
|
622 | 421 |
]. |
422 |
^ false |
|
4438 | 423 |
|
424 |
"Modified: / 22.3.1999 / 12:45:42 / stefan" |
|
622 | 425 |
! |
426 |
||
10776 | 427 |
catchInDebugger |
428 |
"if set, the debugger will handle this signal in its event loop and will close itself |
|
429 |
without asking for close-confirmation. |
|
430 |
This allows for debugged processes to be terminated without a user confirmation dialog |
|
431 |
(for now, this is used in expecco's hard-terminate function to shut down any open debuggers |
|
432 |
together with the test-process)" |
|
433 |
||
434 |
^ false |
|
435 |
! |
|
436 |
||
8681
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
437 |
exceptionHandlerFor:anException in:aContext |
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
438 |
"answer the exceptionHandler for anException from aContext." |
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
439 |
|
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
440 |
^ self |
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
441 |
! |
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
442 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
443 |
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
|
444 |
"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
|
445 |
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
|
446 |
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
|
447 |
|
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 |
(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
|
450 |
or:[(theContext argAt:2) == originator]) ifTrue:[ |
16562 | 451 |
(self == signal or:[self accepts:signal]) ifTrue:[ |
452 |
^ (theContext argAt:1) ? [nil] |
|
453 |
] |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
454 |
]. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
455 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
456 |
^ nil |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
457 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
458 |
"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
|
459 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
460 |
|
4547
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
461 |
handlerProtectedBlock:doBlock inContext:context |
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
462 |
"set the handlerProtectedBlock in context" |
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 |
context selector == #handle:do: ifTrue:[ |
16562 | 465 |
context argAt:2 put:doBlock. |
4547
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
466 |
] ifFalse:[context selector == #handle:from:do: ifTrue:[ |
16562 | 467 |
context argAt:3 put:doBlock. |
4547
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
468 |
]]. |
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
469 |
|
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
470 |
|
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
471 |
|
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
472 |
! |
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
473 |
|
8681
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
474 |
handles:anException |
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
475 |
"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
|
476 |
(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
|
477 |
|
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
478 |
|signal| |
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
479 |
|
15113
20b7764bc56a
use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents:
14961
diff
changeset
|
480 |
signal := anException creator. |
4473
793078981f01
added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
481 |
|
8681
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
482 |
self == signal ifTrue:[^ true]. "quick check" |
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
483 |
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
|
484 |
|
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
485 |
[(signal := signal parent) notNil] whileTrue:[ |
16562 | 486 |
self == signal ifTrue:[^ true]. |
8681
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
487 |
]. |
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
488 |
^ false |
4473
793078981f01
added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
489 |
! |
793078981f01
added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
490 |
|
622 | 491 |
inheritsFrom:anotherSignal |
492 |
"return true, if the receiver is a child of anotherSignal |
|
493 |
(i.e. if handling anotherSignal also handles the receiver) |
|
494 |
This is almost the same as accepts, but returns false, if |
|
495 |
the receiver is identical to anotherSignal." |
|
496 |
||
9271
6be3fa0ab53d
inheritsFrom: should not be used/redefined in the exception
Claus Gittinger <cg@exept.de>
parents:
9180
diff
changeset
|
497 |
<resource: #obsolete> |
6be3fa0ab53d
inheritsFrom: should not be used/redefined in the exception
Claus Gittinger <cg@exept.de>
parents:
9180
diff
changeset
|
498 |
|
622 | 499 |
self == anotherSignal ifTrue:[^ false]. |
500 |
^ anotherSignal accepts:self |
|
3521
4d83701cfc28
care for nil receiver in #isHandledIn:
Claus Gittinger <cg@exept.de>
parents:
3348
diff
changeset
|
501 |
|
4d83701cfc28
care for nil receiver in #isHandledIn:
Claus Gittinger <cg@exept.de>
parents:
3348
diff
changeset
|
502 |
"Modified: / 6.6.1998 / 20:37:47 / cg" |
622 | 503 |
! |
504 |
||
6200 | 505 |
isControlInterrupt |
506 |
^ false |
|
507 |
||
508 |
"Created: / 16.11.2001 / 16:12:20 / cg" |
|
509 |
! |
|
510 |
||
6631
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
511 |
isExceptionCreator |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
512 |
"return true, if the receiver can create exceptions, |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
513 |
this includes #raise, #raiseRequest as well as the behavior of |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
514 |
an exception handler, such as the #accepts: and #handles: messages" |
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 |
^ true |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
517 |
! |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
518 |
|
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
519 |
isExceptionHandler |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
520 |
"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
|
521 |
especially to the #accepts: and #handles: messages" |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
522 |
|
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
523 |
^ true |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
524 |
! |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
525 |
|
622 | 526 |
isHandled |
527 |
"return true, if there is a handler for the receiver signal. |
|
528 |
Raising an unhandled signal will usually lead into the debugger, |
|
2689 | 529 |
but can be caught globally by setting Exceptions EmergencyHandler." |
622 | 530 |
|
4676 | 531 |
^ GenericException exception:self isHandledIn:(thisContext sender). |
622 | 532 |
! |
533 |
||
534 |
isHandledIn:aContext |
|
16562 | 535 |
"return true, if there is a handler for the receiver signal in the |
622 | 536 |
contextChain starting with aContext." |
537 |
||
4676 | 538 |
^ GenericException exception:self isHandledIn:aContext |
622 | 539 |
! |
540 |
||
541 |
isQuerySignal |
|
1249 | 542 |
"return true, if this is a querySignal - always return false here" |
543 |
||
622 | 544 |
^ false |
1249 | 545 |
|
546 |
"Modified: 22.4.1996 / 13:45:06 / cg" |
|
622 | 547 |
! ! |
548 |
||
549 |
!Signal methodsFor:'raising'! |
|
550 |
||
551 |
raise |
|
4438 | 552 |
"raise a signal nonproceedable. |
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
553 |
The signals notifierString is used as messageText." |
622 | 554 |
|
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
555 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
556 |
|
13010 | 557 |
^ self newException |
16562 | 558 |
raiseIn:thisContext sender |
1326 | 559 |
|
13010 | 560 |
"Created: / 23-07-1999 / 14:07:17 / stefan" |
561 |
"Modified: / 10-08-2010 / 09:58:57 / cg" |
|
622 | 562 |
! |
563 |
||
564 |
raiseErrorString:aString |
|
1326 | 565 |
"raise a signal nonproceedable. |
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
566 |
The argument is used as messageText." |
622 | 567 |
|
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
568 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
569 |
|
13010 | 570 |
^ self newException |
16562 | 571 |
raiseErrorString:aString in:thisContext sender |
1326 | 572 |
|
13010 | 573 |
"Created: / 23-07-1999 / 14:07:33 / stefan" |
574 |
"Modified: / 10-08-2010 / 09:59:22 / cg" |
|
622 | 575 |
! |
576 |
||
5685 | 577 |
raiseErrorString:aString in:aContext |
578 |
"raise a signal nonproceedable. |
|
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
579 |
The argument is used as messageText." |
5685 | 580 |
|
581 |
<context: #return> |
|
582 |
||
13010 | 583 |
^ self newException |
16562 | 584 |
raiseErrorString:aString in:aContext |
5685 | 585 |
|
13010 | 586 |
"Created: / 23-07-1999 / 14:07:33 / stefan" |
587 |
"Modified: / 10-08-2010 / 09:59:58 / cg" |
|
5685 | 588 |
! |
589 |
||
16562 | 590 |
raiseFrom:something |
1326 | 591 |
"raise a signal nonproceedable. |
4438 | 592 |
The argument, something is passed both as parameter and originator." |
16562 | 593 |
|
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
594 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
595 |
|
8730 | 596 |
^ (self newException |
16562 | 597 |
suspendedContext:(thisContext sender) parameter:something originator:something) |
598 |
raise |
|
1326 | 599 |
|
13010 | 600 |
"Created: / 23-07-1999 / 14:07:59 / stefan" |
601 |
"Modified: / 10-08-2010 / 09:58:36 / cg" |
|
622 | 602 |
! |
603 |
||
604 |
raiseRequest |
|
1326 | 605 |
"raise a signal proceedable. |
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
606 |
The signals notifierString is used as messageText." |
622 | 607 |
|
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
608 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
609 |
|
13010 | 610 |
^ self newException |
16562 | 611 |
raiseRequestIn:thisContext sender |
1326 | 612 |
|
13010 | 613 |
"Created: / 23-07-1999 / 14:08:24 / stefan" |
614 |
"Modified: / 10-08-2010 / 10:00:13 / cg" |
|
622 | 615 |
! |
616 |
||
4759
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
617 |
raiseRequestErrorString:aString |
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
618 |
"raise a signal proceedable. |
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
619 |
The argument, aString is used as messageText." |
4759
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
620 |
|
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
621 |
<context: #return> |
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
622 |
|
13010 | 623 |
^ self newException |
16562 | 624 |
raiseRequestErrorString:aString in:thisContext sender |
13010 | 625 |
|
626 |
"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
|
627 |
! |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
628 |
|
16562 | 629 |
raiseRequestFrom:something |
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
630 |
"raise a signal proceedable. |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
631 |
The argument, something is passed both as parameter and originator." |
16562 | 632 |
|
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
633 |
<context: #return> |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
634 |
|
8730 | 635 |
^ (self newException |
16562 | 636 |
suspendedContext:(thisContext sender) parameter:something originator:something) |
637 |
raiseRequest |
|
8685
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 |
"Modified: / 2.5.1996 / 16:36:38 / cg" |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
640 |
"Modified: / 5.3.1998 / 16:52:46 / stefan" |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
641 |
"Created: / 23.7.1999 / 14:08:36 / stefan" |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
642 |
! |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
643 |
|
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
644 |
raiseRequestWith:aParameter |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
645 |
"raise a signal proceedable. |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
646 |
The signals notifierString is used as messageText." |
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 |
<context: #return> |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
649 |
|
13010 | 650 |
^ self newException |
16562 | 651 |
raiseRequestWith:aParameter in:thisContext sender |
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
652 |
|
13010 | 653 |
"Created: / 23-07-1999 / 14:08:48 / stefan" |
654 |
"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
|
655 |
! |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
656 |
|
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
657 |
raiseRequestWith:aParameter errorString:aString |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
658 |
"raise a signal proceedable. |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
659 |
The argument, aString is used as messageText." |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
660 |
|
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
661 |
<context: #return> |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
662 |
|
13010 | 663 |
^ self newException |
16562 | 664 |
raiseRequestWith:aParameter errorString:aString in:thisContext sender |
4759
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
665 |
|
13010 | 666 |
"Created: / 23-07-1999 / 14:08:57 / stefan" |
667 |
"Modified: / 10-08-2010 / 10:01:38 / cg" |
|
4759
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
668 |
! |
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
669 |
|
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
670 |
raiseRequestWith:aParameter errorString:aString in:aContext |
3103 | 671 |
"raise a signal proceedable. |
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
672 |
The argument, aString is used as messageText. |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
673 |
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
|
674 |
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
|
675 |
|
8732 | 676 |
<context: #return> |
677 |
||
13010 | 678 |
^ self newException |
16562 | 679 |
raiseRequestWith:aParameter errorString:aString in:aContext |
3103 | 680 |
|
13010 | 681 |
"Created: / 23-07-1999 / 14:09:07 / stefan" |
682 |
"Modified: / 10-08-2010 / 10:02:08 / cg" |
|
3103 | 683 |
! |
684 |
||
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
685 |
raiseRequestWith:aParameter in:aContext |
1326 | 686 |
"raise a signal proceedable. |
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
687 |
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
|
688 |
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
|
689 |
|
8732 | 690 |
<context: #return> |
691 |
||
13010 | 692 |
^ self newException |
16562 | 693 |
raiseRequestWith:aParameter in:aContext |
13010 | 694 |
|
695 |
"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
|
696 |
! |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
697 |
|
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
698 |
raiseSignal |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
699 |
"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
|
700 |
The signals notifierString is used as messageText." |
622 | 701 |
|
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
702 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
703 |
|
8730 | 704 |
^ (self newException |
16562 | 705 |
suspendedContext:thisContext sender) |
706 |
raiseSignal |
|
1326 | 707 |
|
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
708 |
"Modified: / 10.11.2001 / 15:13:34 / cg" |
622 | 709 |
! |
710 |
||
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
711 |
raiseSignal:errorMessage |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
712 |
"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
|
713 |
The argument, errorMessage is used as messageText." |
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 |
<context: #return> |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
716 |
|
8730 | 717 |
^ (self newException |
16562 | 718 |
suspendedContext:(thisContext sender) errorString:errorMessage) |
719 |
raiseSignal. |
|
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
720 |
|
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
721 |
"Modified: / 07-08-2004 / 19:24:00 / stefan" |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
722 |
! |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
723 |
|
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
724 |
raiseSignal:errorMessage with:aParameter |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
725 |
"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
|
726 |
The argument, errorMessage is used as messageText." |
622 | 727 |
|
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
728 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
729 |
|
8730 | 730 |
^ (self newException |
16562 | 731 |
suspendedContext:(thisContext sender) parameter:aParameter errorString:errorMessage) |
732 |
raiseSignal. |
|
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
733 |
|
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
734 |
"Modified: / 07-08-2004 / 19:10:40 / stefan" |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
735 |
! |
1326 | 736 |
|
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
737 |
raiseSignalErrorString:aString |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
738 |
"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
|
739 |
The argument, aString is used as messageText." |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
740 |
|
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
741 |
<context: #return> |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
742 |
|
8730 | 743 |
^ (self newException |
16562 | 744 |
suspendedContext:(thisContext sender) errorString:aString) |
745 |
raiseSignal. |
|
622 | 746 |
! |
747 |
||
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
748 |
raiseSignalWith:aParameter |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
749 |
"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
|
750 |
The argument, aParameter is passed as parameter." |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
751 |
|
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
752 |
<context: #return> |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
753 |
|
8730 | 754 |
^ (self newException |
16562 | 755 |
suspendedContext:(thisContext sender) parameter:aParameter) |
756 |
raiseSignal. |
|
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
757 |
! |
622 | 758 |
|
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
759 |
raiseSignalWith:aParameter errorString:aString |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
760 |
"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
|
761 |
The argument, aString is used as messageText, |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
762 |
aParameter is passed as exception parameter." |
1326 | 763 |
|
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
764 |
<context: #return> |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
765 |
|
8730 | 766 |
^ (self newException |
16562 | 767 |
suspendedContext:(thisContext sender) parameter:aParameter errorString:aString) |
768 |
raiseSignal. |
|
622 | 769 |
! |
770 |
||
771 |
raiseWith:aParameter |
|
1326 | 772 |
"raise a signal nonproceedable. |
4438 | 773 |
The argument, aParameter is passed as parameter." |
622 | 774 |
|
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
775 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
776 |
|
13010 | 777 |
^ self newException |
16562 | 778 |
raiseWith:aParameter in:thisContext sender |
1326 | 779 |
|
13010 | 780 |
"Created: / 23-07-1999 / 14:09:27 / stefan" |
781 |
"Modified: / 10-08-2010 / 10:02:51 / cg" |
|
622 | 782 |
! |
783 |
||
784 |
raiseWith:aParameter errorString:aString |
|
4438 | 785 |
"raise a signal nonproceedable. |
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
786 |
The argument, aString is used as messageText, |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
787 |
aParameter is passed as exception parameter." |
622 | 788 |
|
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
789 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
790 |
|
13010 | 791 |
^ self newException |
16562 | 792 |
raiseWith:aParameter errorString:aString in:thisContext sender |
1326 | 793 |
|
13010 | 794 |
"Created: / 23-07-1999 / 14:09:36 / stefan" |
795 |
"Modified: / 10-08-2010 / 10:03:29 / cg" |
|
1326 | 796 |
! |
797 |
||
798 |
raiseWith:aParameter errorString:aString in:aContext |
|
4438 | 799 |
"raise a signal nonproceedable. |
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
800 |
The argument, aString is used as messageText, aParameter is passed |
1608 | 801 |
as exception parameter. |
802 |
The additional context is passed as the context responsible for the raise, |
|
803 |
allowing a raise to mimicri the exception happened somewhere else." |
|
804 |
||
8732 | 805 |
<context: #return> |
806 |
||
13010 | 807 |
^ self newException |
16562 | 808 |
raiseWith:aParameter errorString:aString in:aContext |
1326 | 809 |
|
13010 | 810 |
"Created: / 23-07-1999 / 14:09:46 / stefan" |
811 |
"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
|
812 |
! |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
813 |
|
9180 | 814 |
raiseWith:aParameter in:aContext |
815 |
"raise a signal nonproceedable. |
|
816 |
The argument, aParameter is passed as parameter. |
|
817 |
The additional context is passed as the context responsible for the raise, |
|
818 |
allowing a raise to mimicri the exception happened somewhere else." |
|
819 |
||
820 |
<context: #return> |
|
821 |
||
13010 | 822 |
^ self newException |
16562 | 823 |
raiseWith:aParameter in:aContext |
13010 | 824 |
|
825 |
"Modified: / 10-08-2010 / 10:03:05 / cg" |
|
622 | 826 |
! ! |
827 |
||
1 | 828 |
!Signal methodsFor:'save evaluation'! |
829 |
||
622 | 830 |
catch:aBlock |
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
831 |
"evaluate the argument, aBlock. |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
832 |
If the receiver-signal is raised during evaluation, abort |
16562 | 833 |
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
|
834 |
This is the catch & throw mechanism found in other languages, |
20266 | 835 |
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
|
836 |
|
9079 | 837 |
|raiseOccurred| |
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
838 |
|
9079 | 839 |
raiseOccurred := false. |
840 |
self handle:[:ex | raiseOccurred := true. ex return] do:aBlock. |
|
841 |
^ raiseOccurred |
|
622 | 842 |
|
9079 | 843 |
" |
844 |
Object messageNotUnderstoodSignal catch:[ |
|
20266 | 845 |
123 size open |
9079 | 846 |
] |
847 |
" |
|
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
848 |
! |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
849 |
|
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
850 |
deferAfter:aBlock |
12006 | 851 |
" evaluate the argument, aBlock. |
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
852 |
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
|
853 |
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
|
854 |
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
|
855 |
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
|
856 |
and only a single raise is performed after the blocks evaluation. |
622 | 857 |
|
16562 | 858 |
Deferring makes sense for some signals, such as UserInterrupt or AbortSignal, |
859 |
which must occasionally be delayed temporarily until a save place is reached |
|
20820 | 860 |
(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
|
861 |
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
|
862 |
|
16562 | 863 |
|caughtException result| |
622 | 864 |
|
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
865 |
self handle:[:ex | |
20820 | 866 |
caughtException isNil ifTrue:[ |
867 |
caughtException := ex. |
|
868 |
]. |
|
869 |
ex proceedWith:nil |
|
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
870 |
] do:[ |
20820 | 871 |
result := aBlock value. |
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
872 |
]. |
16562 | 873 |
caughtException notNil ifTrue:[ |
20820 | 874 |
caughtException suspendedContext:thisContext. |
6429
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
875 |
|
20820 | 876 |
"/ the signal was raised during the execution of aBlock above. |
877 |
"/ Raise it now (delayed). |
|
878 |
caughtException raiseSignal |
|
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 |
^ result |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
881 |
|
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
882 |
" |
6429
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
883 |
|s| |
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
884 |
|
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
885 |
s := Signal new mayProceed:true. |
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
886 |
s deferAfter:[ |
20820 | 887 |
s raiseRequestWith:'hello' errorString:'eeee' |
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
888 |
] |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
889 |
" |
622 | 890 |
! |
891 |
||
12062 | 892 |
evaluate:aBlock ifRaised:exceptionValue |
893 |
"evaluate the argument, aBlock and return its value. |
|
894 |
If the receiver-signal is raised during evaluation, abort |
|
16562 | 895 |
the evaluation and return the value from exceptionValue. |
12062 | 896 |
This is similar to the catch & throw mechanism found in other languages" |
897 |
||
898 |
^ self handle:[:ex | exceptionValue value] do:aBlock. |
|
899 |
||
900 |
" |
|
16562 | 901 |
Object messageNotUnderstoodSignal |
902 |
evaluate:[ 123 size open ] |
|
903 |
ifRaised:[ self halt ] |
|
12062 | 904 |
" |
905 |
! |
|
906 |
||
1 | 907 |
handle:handleBlock do:aBlock |
908 |
"evaluate the argument, aBlock. |
|
909 |
If the receiver-signal is raised during evaluation, |
|
910 |
evaluate the handleBlock passing it an Exception argument. |
|
911 |
The handler may decide how to react to the signal by sending |
|
912 |
a corresponding message to the exception (see there). |
|
913 |
If the signal is not raised, return the value of evaluating |
|
914 |
aBlock." |
|
915 |
||
4547
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
916 |
<context: #return> |
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
917 |
<exception: #handle> |
95 | 918 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
919 |
"/ thisContext markForHandle. -- same as above pragma |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
920 |
^ aBlock value "the real logic is in Exception>>doRaise" |
120 | 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 |
Object messageNotUnderstoodSignal handle:[:ex | |
16562 | 924 |
'oops' printNL. |
925 |
ex return |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
926 |
] do:[ |
16562 | 927 |
123 size open |
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
928 |
] |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
929 |
" |
95 | 930 |
|
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 |
|num| |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
933 |
|
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
934 |
num := 0. |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
935 |
Number divisionByZeroSignal handle:[:ex | |
16562 | 936 |
'oops' printNL. |
937 |
ex return |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
938 |
] do:[ |
16562 | 939 |
123 / num |
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
940 |
] |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
941 |
" |
4438 | 942 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
943 |
"Modified: / 25.7.1999 / 19:43:01 / stefan" |
44 | 944 |
! |
945 |
||
362 | 946 |
handle:handleBlock from:anObject do:aBlock |
947 |
"evaluate the argument, aBlock. |
|
948 |
If the receiver-signal is raised during evaluation, |
|
949 |
and the exception originated from anObject, |
|
950 |
evaluate the handleBlock passing it an Exception argument. |
|
951 |
The handler may decide how to react to the signal by sending |
|
952 |
a corresponding message to the exception (see there). |
|
953 |
If the signal is not raised, return the value of evaluating |
|
954 |
aBlock." |
|
955 |
||
4547
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
956 |
<context: #return> |
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
957 |
<exception: #handle> |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
958 |
|
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
959 |
"/ thisContext markForHandle. -- same as above pragma |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
960 |
^ aBlock value "the real logic is in Exception>>doRaise" |
362 | 961 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
962 |
" |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
963 |
the first open will be caught; the second not: |
362 | 964 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
965 |
|o1 o2| |
362 | 966 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
967 |
o1 := 123. |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
968 |
o2 := nil. |
16562 | 969 |
Object messageNotUnderstoodSignal |
970 |
handle: |
|
971 |
[:ex | |
|
972 |
'oops' printNL. |
|
973 |
ex proceed |
|
974 |
] |
|
975 |
from:o1 |
|
976 |
do: |
|
977 |
[ |
|
978 |
o1 open. |
|
979 |
o2 open |
|
980 |
] |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
981 |
" |
4438 | 982 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
983 |
"Modified: / 25.7.1999 / 19:43:40 / stefan" |
362 | 984 |
! |
985 |
||
419 | 986 |
ignoreIn:aBlock |
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
987 |
"evaluate the argument, aBlock. |
16562 | 988 |
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
|
989 |
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
|
990 |
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
|
991 |
often leads to followup-errors." |
159 | 992 |
|
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
993 |
^ self handle:[:ex | ex proceedWith:nil] do:aBlock. |
159 | 994 |
|
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
995 |
" |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
996 |
Object messageNotUnderstoodSignal ignoreIn:[ |
16562 | 997 |
123 size open |
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
998 |
] |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
999 |
" |
1 | 1000 |
! ! |
1001 |
||
2207 | 1002 |
!Signal class methodsFor:'documentation'! |
1249 | 1003 |
|
1004 |
version |
|
18726 | 1005 |
^ '$Header$' |
12062 | 1006 |
! |
1007 |
||
1008 |
version_CVS |
|
18726 | 1009 |
^ '$Header$' |
1249 | 1010 |
! ! |
18726 | 1011 |