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