author | Claus Gittinger <cg@exept.de> |
Tue, 08 May 2018 13:09:42 +0200 | |
changeset 22797 | 094ff40472f3 |
parent 22496 | 0bfdeef77a63 |
child 23302 | a5d66fd32992 |
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 |
|
622 | 203 |
!Signal methodsFor:'accessing'! |
1 | 204 |
|
15375 | 205 |
creator |
16501 | 206 |
"return the creator of the exception (for exception protocol compatibilty). |
207 |
For class based exceptions, that is the exception class; |
|
18726 | 208 |
for signals, that is the signal itself. |
209 |
This used to be called 'signal' in earlier versions, |
|
210 |
but due to the conflict with VSE, Squeak and others, |
|
211 |
where 'signal' means 'raise', 'signal' was obsoleted by this method." |
|
15375 | 212 |
|
213 |
^ self |
|
214 |
! |
|
215 |
||
622 | 216 |
errorString |
7206 | 217 |
"errorString is deprecated, use description instead" |
218 |
||
219 |
<resource:#obsolete> |
|
1 | 220 |
|
4563 | 221 |
^ self description |
622 | 222 |
! |
159 | 223 |
|
622 | 224 |
handlerBlock |
16562 | 225 |
"return the handlerblock - if non-nil, this will be evaluated with the exception |
622 | 226 |
object as argument, if no #handle:do: context was found on the stack." |
227 |
||
228 |
^ handlerBlock |
|
1 | 229 |
! |
230 |
||
622 | 231 |
handlerBlock:aOneArgBlock |
16562 | 232 |
"set the handlerblock - this will be evaluated with the exception |
622 | 233 |
object as argument, if no #handle:do: context was found on the stack." |
159 | 234 |
|
622 | 235 |
handlerBlock := aOneArgBlock |
236 |
! |
|
159 | 237 |
|
622 | 238 |
mayProceed |
239 |
"return the signals ability to proceed. |
|
240 |
This flag is (currently) not checked by the system; |
|
241 |
be prepared for changes here, to eventually have nonProceedable |
|
242 |
signals refuse to let you continue execution." |
|
1 | 243 |
|
622 | 244 |
^ mayProceed |
1 | 245 |
! |
246 |
||
247 |
mayProceed:aBoolean |
|
44 | 248 |
"set/clear the signals ability to proceed. |
419 | 249 |
This flag is (currently) not checked by the system; |
250 |
be prepared for changes here, to eventually have nonProceedable |
|
251 |
signals refuse to let you continue execution." |
|
1 | 252 |
|
253 |
mayProceed := aBoolean |
|
254 |
! |
|
255 |
||
622 | 256 |
nameClass:aClass message:aSelector |
257 |
"this sets the class & selector of a method which returns |
|
258 |
that signal - this is simply for documentation purposes - |
|
259 |
see Signal>>printOn: implementation. |
|
260 |
(took me a while to find that one out ;-)" |
|
419 | 261 |
|
622 | 262 |
nameClass := aClass. |
263 |
message := aSelector |
|
419 | 264 |
! |
265 |
||
622 | 266 |
notifierString |
267 |
"return the notifier string" |
|
159 | 268 |
|
622 | 269 |
^ notifierString |
270 |
! |
|
271 |
||
272 |
notifierString:aString |
|
273 |
"set the notifier string" |
|
274 |
||
275 |
notifierString := aString |
|
159 | 276 |
! |
277 |
||
14961 | 278 |
originalSignal |
279 |
"return the signal/exception which was originally raised. |
|
20427 | 280 |
For noHandler, that is my unhandled signal; for others, that's the exception itself." |
14961 | 281 |
|
282 |
^ self. |
|
283 |
! |
|
284 |
||
159 | 285 |
parent |
286 |
"return the parent-signal of the receiver" |
|
287 |
||
288 |
^ parent |
|
289 |
! |
|
290 |
||
16562 | 291 |
parent:aSignal |
622 | 292 |
"set the parent-signal of the receiver." |
293 |
||
294 |
parent := aSignal |
|
3004
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
295 |
! |
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 |
parent:aSignal mayProceed:aBoolean |
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
298 |
"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
|
299 |
|
3010 | 300 |
parent := aSignal. |
301 |
mayProceed := aBoolean. |
|
3004
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
302 |
|
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
303 |
"Modified: 8.10.1997 / 11:56:11 / cg" |
622 | 304 |
! ! |
305 |
||
5835 | 306 |
!Signal methodsFor:'converting'! |
307 |
||
8239 | 308 |
, anExceptionHandler |
309 |
"return a SignalSet with myself and anExceptionHandler" |
|
5835 | 310 |
|
8239 | 311 |
^ SignalSet with:self with:anExceptionHandler |
5835 | 312 |
! ! |
313 |
||
622 | 314 |
!Signal methodsFor:'copying'! |
315 |
||
10953 | 316 |
deepCopyUsing:aDictionary postCopySelector:postCopySelector |
622 | 317 |
"raise an error - deepCopy is not allowed for signals" |
1 | 318 |
|
622 | 319 |
^ self deepCopyError |
3348
37b0481be091
must catch #deppCopyUsing: instead of #deepCopy.
Claus Gittinger <cg@exept.de>
parents:
3280
diff
changeset
|
320 |
|
37b0481be091
must catch #deppCopyUsing: instead of #deepCopy.
Claus Gittinger <cg@exept.de>
parents:
3280
diff
changeset
|
321 |
"Created: / 31.3.1998 / 15:43:01 / cg" |
622 | 322 |
! ! |
323 |
||
8681
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
324 |
!Signal methodsFor:'exception creation'! |
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
325 |
|
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
326 |
newException |
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
327 |
"{ Pragma: +inlineNew }" |
8681
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
328 |
"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
|
329 |
Subclasses may redefine this method" |
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
330 |
|
21046 | 331 |
|exception| |
332 |
||
333 |
parent notNil ifTrue:[ |
|
334 |
"parent may be a class based signal" |
|
335 |
exception := parent newException. |
|
336 |
] ifFalse:[ |
|
337 |
exception := Exception basicNew. |
|
338 |
]. |
|
339 |
||
340 |
^ exception creator:self |
|
8681
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
341 |
|
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
342 |
"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
|
343 |
"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
|
344 |
! ! |
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
345 |
|
622 | 346 |
!Signal methodsFor:'instance creation'! |
1 | 347 |
|
622 | 348 |
newSignal |
349 |
"create a new signal, using the receiver as a prototype and |
|
350 |
setting the parent of the new signal to the receiver." |
|
1 | 351 |
|
3010 | 352 |
^ (self copy) parent:self |
3004
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
353 |
|
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
354 |
"Modified: 8.10.1997 / 11:53:06 / cg" |
70 | 355 |
! |
356 |
||
622 | 357 |
newSignalMayProceed:aBoolean |
358 |
"create a new signal, using the receiver as a prototype and |
|
359 |
setting the parent of the new signal to the receiver." |
|
362 | 360 |
|
3010 | 361 |
^ (self copy) parent:self mayProceed:aBoolean |
70 | 362 |
|
3004
220af5090ec2
added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
363 |
"Modified: 8.10.1997 / 11:57:13 / cg" |
1 | 364 |
! ! |
365 |
||
5570 | 366 |
!Signal methodsFor:'printing & storing'! |
159 | 367 |
|
4563 | 368 |
description |
369 |
"return the notifier string. |
|
370 |
If the notifier string starts with space, prepend |
|
371 |
the parents notifier string" |
|
372 |
||
6116 | 373 |
|s| |
374 |
||
4563 | 375 |
notifierString isNil ifTrue:[ |
16562 | 376 |
^ parent description |
5949 | 377 |
]. |
6116 | 378 |
s := notifierString asString. |
379 |
(s startsWith:Character space) ifTrue:[ |
|
16562 | 380 |
^ parent description, s |
5949 | 381 |
]. |
6116 | 382 |
^ s |
4563 | 383 |
|
384 |
" |
|
8292 | 385 |
Error description |
4563 | 386 |
" |
387 |
||
388 |
"Modified: / 12.3.1998 / 15:04:41 / stefan" |
|
389 |
! |
|
390 |
||
14961 | 391 |
descriptionForDebugger |
16562 | 392 |
"return the description string of the signal which is used in the |
14961 | 393 |
debugger title area" |
394 |
||
395 |
^ self description. |
|
396 |
! |
|
397 |
||
159 | 398 |
printOn:aStream |
399 |
"append a printed representation of the receiver on aStream" |
|
400 |
||
401 |
nameClass notNil ifTrue:[ |
|
16562 | 402 |
nameClass isBehavior ifTrue:[ |
403 |
aStream nextPutAll:nameClass name. |
|
404 |
] ifFalse:[ |
|
405 |
nameClass printOn:aStream. |
|
406 |
]. |
|
407 |
aStream space. |
|
408 |
aStream nextPutAll:message. |
|
409 |
^ self |
|
159 | 410 |
]. |
411 |
^ super printOn:aStream |
|
412 |
! ! |
|
413 |
||
622 | 414 |
!Signal methodsFor:'queries'! |
415 |
||
416 |
accepts:aSignal |
|
417 |
"return true, if the receiver accepts the argument, aSignal. |
|
418 |
(i.e. the receiver is aSignal or a parent of it). False otherwise." |
|
419 |
||
420 |
|s| |
|
421 |
||
4527 | 422 |
self == aSignal ifTrue:[^ true]. |
622 | 423 |
aSignal isQuerySignal ifTrue:[^ false]. |
424 |
||
8681
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
425 |
s := aSignal parent. |
622 | 426 |
[s notNil] whileTrue:[ |
16562 | 427 |
self == s ifTrue:[^ true]. |
428 |
s := s parent |
|
622 | 429 |
]. |
430 |
^ false |
|
4438 | 431 |
|
432 |
"Modified: / 22.3.1999 / 12:45:42 / stefan" |
|
622 | 433 |
! |
434 |
||
10776 | 435 |
catchInDebugger |
436 |
"if set, the debugger will handle this signal in its event loop and will close itself |
|
437 |
without asking for close-confirmation. |
|
438 |
This allows for debugged processes to be terminated without a user confirmation dialog |
|
439 |
(for now, this is used in expecco's hard-terminate function to shut down any open debuggers |
|
440 |
together with the test-process)" |
|
441 |
||
442 |
^ false |
|
443 |
! |
|
444 |
||
8681
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
445 |
exceptionHandlerFor:anException in:aContext |
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
446 |
"answer the exceptionHandler for anException from aContext." |
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
447 |
|
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
448 |
^ self |
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 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
451 |
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
|
452 |
"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
|
453 |
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
|
454 |
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
|
455 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
456 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
457 |
(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
|
458 |
or:[(theContext argAt:2) == originator]) ifTrue:[ |
16562 | 459 |
(self == signal or:[self accepts:signal]) ifTrue:[ |
460 |
^ (theContext argAt:1) ? [nil] |
|
461 |
] |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
462 |
]. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
463 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
464 |
^ nil |
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 |
"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
|
467 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
468 |
|
4547
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
469 |
handlerProtectedBlock:doBlock inContext:context |
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
470 |
"set the handlerProtectedBlock in context" |
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 |
context selector == #handle:do: ifTrue:[ |
16562 | 473 |
context argAt:2 put:doBlock. |
4547
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
474 |
] ifFalse:[context selector == #handle:from:do: ifTrue:[ |
16562 | 475 |
context argAt:3 put:doBlock. |
4547
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
476 |
]]. |
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
477 |
|
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 |
|
8681
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
482 |
handles:anException |
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
483 |
"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
|
484 |
(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
|
485 |
|
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
486 |
|signal| |
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
487 |
|
15113
20b7764bc56a
use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents:
14961
diff
changeset
|
488 |
signal := anException creator. |
4473
793078981f01
added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
489 |
|
8681
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
490 |
self == signal ifTrue:[^ true]. "quick check" |
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
491 |
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
|
492 |
|
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
493 |
[(signal := signal parent) notNil] whileTrue:[ |
16562 | 494 |
self == signal ifTrue:[^ true]. |
8681
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
495 |
]. |
38aa963476a5
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8384
diff
changeset
|
496 |
^ false |
4473
793078981f01
added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
497 |
! |
793078981f01
added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
498 |
|
622 | 499 |
inheritsFrom:anotherSignal |
500 |
"return true, if the receiver is a child of anotherSignal |
|
501 |
(i.e. if handling anotherSignal also handles the receiver) |
|
502 |
This is almost the same as accepts, but returns false, if |
|
503 |
the receiver is identical to anotherSignal." |
|
504 |
||
9271
6be3fa0ab53d
inheritsFrom: should not be used/redefined in the exception
Claus Gittinger <cg@exept.de>
parents:
9180
diff
changeset
|
505 |
<resource: #obsolete> |
6be3fa0ab53d
inheritsFrom: should not be used/redefined in the exception
Claus Gittinger <cg@exept.de>
parents:
9180
diff
changeset
|
506 |
|
622 | 507 |
self == anotherSignal ifTrue:[^ false]. |
508 |
^ anotherSignal accepts:self |
|
3521
4d83701cfc28
care for nil receiver in #isHandledIn:
Claus Gittinger <cg@exept.de>
parents:
3348
diff
changeset
|
509 |
|
4d83701cfc28
care for nil receiver in #isHandledIn:
Claus Gittinger <cg@exept.de>
parents:
3348
diff
changeset
|
510 |
"Modified: / 6.6.1998 / 20:37:47 / cg" |
622 | 511 |
! |
512 |
||
6200 | 513 |
isControlInterrupt |
514 |
^ false |
|
515 |
||
516 |
"Created: / 16.11.2001 / 16:12:20 / cg" |
|
517 |
! |
|
518 |
||
6631
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
519 |
isExceptionCreator |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
520 |
"return true, if the receiver can create exceptions, |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
521 |
this includes #raise, #raiseRequest as well as the behavior of |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
522 |
an exception handler, such as the #accepts: and #handles: messages" |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
523 |
|
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
524 |
^ true |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
525 |
! |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
526 |
|
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
527 |
isExceptionHandler |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
528 |
"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
|
529 |
especially to the #accepts: and #handles: messages" |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
530 |
|
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
531 |
^ true |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
532 |
! |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6518
diff
changeset
|
533 |
|
622 | 534 |
isHandled |
535 |
"return true, if there is a handler for the receiver signal. |
|
536 |
Raising an unhandled signal will usually lead into the debugger, |
|
2689 | 537 |
but can be caught globally by setting Exceptions EmergencyHandler." |
622 | 538 |
|
4676 | 539 |
^ GenericException exception:self isHandledIn:(thisContext sender). |
622 | 540 |
! |
541 |
||
542 |
isHandledIn:aContext |
|
16562 | 543 |
"return true, if there is a handler for the receiver signal in the |
622 | 544 |
contextChain starting with aContext." |
545 |
||
4676 | 546 |
^ GenericException exception:self isHandledIn:aContext |
622 | 547 |
! |
548 |
||
22066 | 549 |
isQuery |
550 |
"return true, if this is a query" |
|
551 |
||
552 |
^ false |
|
553 |
||
554 |
"Created: / 21-07-2017 / 00:44:48 / cg" |
|
555 |
! |
|
556 |
||
622 | 557 |
isQuerySignal |
1249 | 558 |
"return true, if this is a querySignal - always return false here" |
559 |
||
622 | 560 |
^ false |
1249 | 561 |
|
562 |
"Modified: 22.4.1996 / 13:45:06 / cg" |
|
622 | 563 |
! ! |
564 |
||
565 |
!Signal methodsFor:'raising'! |
|
566 |
||
567 |
raise |
|
4438 | 568 |
"raise a signal nonproceedable. |
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
569 |
The signals notifierString is used as messageText." |
622 | 570 |
|
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
571 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
572 |
|
13010 | 573 |
^ self newException |
16562 | 574 |
raiseIn:thisContext sender |
1326 | 575 |
|
13010 | 576 |
"Created: / 23-07-1999 / 14:07:17 / stefan" |
577 |
"Modified: / 10-08-2010 / 09:58:57 / cg" |
|
622 | 578 |
! |
579 |
||
580 |
raiseErrorString:aString |
|
1326 | 581 |
"raise a signal nonproceedable. |
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
582 |
The argument 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 |
raiseErrorString:aString in:thisContext sender |
1326 | 588 |
|
13010 | 589 |
"Created: / 23-07-1999 / 14:07:33 / stefan" |
590 |
"Modified: / 10-08-2010 / 09:59:22 / cg" |
|
622 | 591 |
! |
592 |
||
5685 | 593 |
raiseErrorString:aString in:aContext |
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." |
5685 | 596 |
|
597 |
<context: #return> |
|
598 |
||
13010 | 599 |
^ self newException |
16562 | 600 |
raiseErrorString:aString in:aContext |
5685 | 601 |
|
13010 | 602 |
"Created: / 23-07-1999 / 14:07:33 / stefan" |
603 |
"Modified: / 10-08-2010 / 09:59:58 / cg" |
|
5685 | 604 |
! |
605 |
||
16562 | 606 |
raiseFrom:something |
1326 | 607 |
"raise a signal nonproceedable. |
4438 | 608 |
The argument, something is passed both as parameter and originator." |
16562 | 609 |
|
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
610 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
611 |
|
8730 | 612 |
^ (self newException |
16562 | 613 |
suspendedContext:(thisContext sender) parameter:something originator:something) |
614 |
raise |
|
1326 | 615 |
|
13010 | 616 |
"Created: / 23-07-1999 / 14:07:59 / stefan" |
617 |
"Modified: / 10-08-2010 / 09:58:36 / cg" |
|
622 | 618 |
! |
619 |
||
620 |
raiseRequest |
|
1326 | 621 |
"raise a signal proceedable. |
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
622 |
The signals notifierString is used as messageText." |
622 | 623 |
|
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
624 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
625 |
|
13010 | 626 |
^ self newException |
16562 | 627 |
raiseRequestIn:thisContext sender |
1326 | 628 |
|
13010 | 629 |
"Created: / 23-07-1999 / 14:08:24 / stefan" |
630 |
"Modified: / 10-08-2010 / 10:00:13 / cg" |
|
622 | 631 |
! |
632 |
||
4759
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
633 |
raiseRequestErrorString:aString |
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
634 |
"raise a signal proceedable. |
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
635 |
The argument, aString is used as messageText." |
4759
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
636 |
|
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
637 |
<context: #return> |
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
638 |
|
13010 | 639 |
^ self newException |
16562 | 640 |
raiseRequestErrorString:aString in:thisContext sender |
13010 | 641 |
|
642 |
"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
|
643 |
! |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
644 |
|
16562 | 645 |
raiseRequestFrom:something |
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
646 |
"raise a signal proceedable. |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
647 |
The argument, something is passed both as parameter and originator." |
16562 | 648 |
|
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
649 |
<context: #return> |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
650 |
|
8730 | 651 |
^ (self newException |
16562 | 652 |
suspendedContext:(thisContext sender) parameter:something originator:something) |
653 |
raiseRequest |
|
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
654 |
|
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
655 |
"Modified: / 2.5.1996 / 16:36:38 / cg" |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
656 |
"Modified: / 5.3.1998 / 16:52:46 / stefan" |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
657 |
"Created: / 23.7.1999 / 14:08:36 / stefan" |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
658 |
! |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
659 |
|
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
660 |
raiseRequestWith:aParameter |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
661 |
"raise a signal proceedable. |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
662 |
The signals notifierString is used as messageText." |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
663 |
|
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
664 |
<context: #return> |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
665 |
|
13010 | 666 |
^ self newException |
16562 | 667 |
raiseRequestWith:aParameter in:thisContext sender |
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
668 |
|
13010 | 669 |
"Created: / 23-07-1999 / 14:08:48 / stefan" |
670 |
"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
|
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 errorString:aString |
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 argument, aString 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 errorString:aString in:thisContext sender |
4759
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
681 |
|
13010 | 682 |
"Created: / 23-07-1999 / 14:08:57 / stefan" |
683 |
"Modified: / 10-08-2010 / 10:01:38 / cg" |
|
4759
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
684 |
! |
99d883e67ec9
added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents:
4676
diff
changeset
|
685 |
|
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
686 |
raiseRequestWith:aParameter errorString:aString in:aContext |
3103 | 687 |
"raise a signal proceedable. |
8685
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 |
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
|
690 |
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
|
691 |
|
8732 | 692 |
<context: #return> |
693 |
||
13010 | 694 |
^ self newException |
16562 | 695 |
raiseRequestWith:aParameter errorString:aString in:aContext |
3103 | 696 |
|
13010 | 697 |
"Created: / 23-07-1999 / 14:09:07 / stefan" |
698 |
"Modified: / 10-08-2010 / 10:02:08 / cg" |
|
3103 | 699 |
! |
700 |
||
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
701 |
raiseRequestWith:aParameter in:aContext |
1326 | 702 |
"raise a signal proceedable. |
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
703 |
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
|
704 |
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
|
705 |
|
8732 | 706 |
<context: #return> |
707 |
||
13010 | 708 |
^ self newException |
16562 | 709 |
raiseRequestWith:aParameter in:aContext |
13010 | 710 |
|
711 |
"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
|
712 |
! |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
713 |
|
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
714 |
raiseSignal |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
715 |
"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
|
716 |
The signals notifierString is used as messageText." |
622 | 717 |
|
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
718 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
719 |
|
8730 | 720 |
^ (self newException |
16562 | 721 |
suspendedContext:thisContext sender) |
722 |
raiseSignal |
|
1326 | 723 |
|
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
724 |
"Modified: / 10.11.2001 / 15:13:34 / cg" |
622 | 725 |
! |
726 |
||
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
727 |
raiseSignal:errorMessage |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
728 |
"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
|
729 |
The argument, errorMessage is used as messageText." |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
730 |
|
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
731 |
<context: #return> |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
732 |
|
8730 | 733 |
^ (self newException |
16562 | 734 |
suspendedContext:(thisContext sender) errorString:errorMessage) |
735 |
raiseSignal. |
|
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
736 |
|
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
737 |
"Modified: / 07-08-2004 / 19:24:00 / stefan" |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
738 |
! |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
739 |
|
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
740 |
raiseSignal:errorMessage with:aParameter |
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." |
622 | 743 |
|
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
744 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
745 |
|
8730 | 746 |
^ (self newException |
16562 | 747 |
suspendedContext:(thisContext sender) parameter:aParameter 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:10:40 / stefan" |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
751 |
! |
1326 | 752 |
|
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
753 |
raiseSignalErrorString:aString |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
754 |
"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, aString is used as messageText." |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
756 |
|
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
757 |
<context: #return> |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
758 |
|
8730 | 759 |
^ (self newException |
16562 | 760 |
suspendedContext:(thisContext sender) errorString:aString) |
761 |
raiseSignal. |
|
622 | 762 |
! |
763 |
||
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
764 |
raiseSignalWith:aParameter |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
765 |
"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
|
766 |
The argument, aParameter is passed as parameter." |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
767 |
|
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
768 |
<context: #return> |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
769 |
|
8730 | 770 |
^ (self newException |
16562 | 771 |
suspendedContext:(thisContext sender) parameter:aParameter) |
772 |
raiseSignal. |
|
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
773 |
! |
622 | 774 |
|
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
775 |
raiseSignalWith:aParameter errorString:aString |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
776 |
"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
|
777 |
The argument, aString is used as messageText, |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
778 |
aParameter is passed as exception parameter." |
1326 | 779 |
|
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
780 |
<context: #return> |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
781 |
|
8730 | 782 |
^ (self newException |
16562 | 783 |
suspendedContext:(thisContext sender) parameter:aParameter errorString:aString) |
784 |
raiseSignal. |
|
622 | 785 |
! |
786 |
||
787 |
raiseWith:aParameter |
|
1326 | 788 |
"raise a signal nonproceedable. |
4438 | 789 |
The argument, aParameter is passed as parameter." |
622 | 790 |
|
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
791 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
792 |
|
13010 | 793 |
^ self newException |
16562 | 794 |
raiseWith:aParameter in:thisContext sender |
1326 | 795 |
|
13010 | 796 |
"Created: / 23-07-1999 / 14:09:27 / stefan" |
797 |
"Modified: / 10-08-2010 / 10:02:51 / cg" |
|
622 | 798 |
! |
799 |
||
800 |
raiseWith:aParameter errorString:aString |
|
4438 | 801 |
"raise a signal nonproceedable. |
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
802 |
The argument, aString is used as messageText, |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
803 |
aParameter is passed as exception parameter." |
622 | 804 |
|
4555
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
805 |
<context: #return> |
892c4529acf2
cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents:
4554
diff
changeset
|
806 |
|
13010 | 807 |
^ self newException |
16562 | 808 |
raiseWith:aParameter errorString:aString in:thisContext sender |
1326 | 809 |
|
13010 | 810 |
"Created: / 23-07-1999 / 14:09:36 / stefan" |
811 |
"Modified: / 10-08-2010 / 10:03:29 / cg" |
|
1326 | 812 |
! |
813 |
||
814 |
raiseWith:aParameter errorString:aString in:aContext |
|
4438 | 815 |
"raise a signal nonproceedable. |
8685
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
816 |
The argument, aString is used as messageText, aParameter is passed |
1608 | 817 |
as exception parameter. |
818 |
The additional context is passed as the context responsible for the raise, |
|
819 |
allowing a raise to mimicri the exception happened somewhere else." |
|
820 |
||
8732 | 821 |
<context: #return> |
822 |
||
13010 | 823 |
^ self newException |
16562 | 824 |
raiseWith:aParameter errorString:aString in:aContext |
1326 | 825 |
|
13010 | 826 |
"Created: / 23-07-1999 / 14:09:46 / stefan" |
827 |
"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
|
828 |
! |
06c1d82512f5
QuerySignal generates Notifications instead of Exceptions.
Stefan Vogel <sv@exept.de>
parents:
8681
diff
changeset
|
829 |
|
9180 | 830 |
raiseWith:aParameter in:aContext |
831 |
"raise a signal nonproceedable. |
|
832 |
The argument, aParameter is passed as parameter. |
|
833 |
The additional context is passed as the context responsible for the raise, |
|
834 |
allowing a raise to mimicri the exception happened somewhere else." |
|
835 |
||
836 |
<context: #return> |
|
837 |
||
13010 | 838 |
^ self newException |
16562 | 839 |
raiseWith:aParameter in:aContext |
13010 | 840 |
|
841 |
"Modified: / 10-08-2010 / 10:03:05 / cg" |
|
622 | 842 |
! ! |
843 |
||
1 | 844 |
!Signal methodsFor:'save evaluation'! |
845 |
||
622 | 846 |
catch:aBlock |
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
847 |
"evaluate the argument, aBlock. |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
848 |
If the receiver-signal is raised during evaluation, abort |
16562 | 849 |
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
|
850 |
This is the catch & throw mechanism found in other languages, |
20266 | 851 |
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
|
852 |
|
9079 | 853 |
|raiseOccurred| |
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
854 |
|
9079 | 855 |
raiseOccurred := false. |
856 |
self handle:[:ex | raiseOccurred := true. ex return] do:aBlock. |
|
857 |
^ raiseOccurred |
|
622 | 858 |
|
9079 | 859 |
" |
860 |
Object messageNotUnderstoodSignal catch:[ |
|
20266 | 861 |
123 size open |
9079 | 862 |
] |
863 |
" |
|
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
864 |
! |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
865 |
|
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
866 |
deferAfter:aBlock |
12006 | 867 |
" evaluate the argument, aBlock. |
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
868 |
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
|
869 |
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
|
870 |
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
|
871 |
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
|
872 |
and only a single raise is performed after the blocks evaluation. |
622 | 873 |
|
16562 | 874 |
Deferring makes sense for some signals, such as UserInterrupt or AbortSignal, |
875 |
which must occasionally be delayed temporarily until a save place is reached |
|
20820 | 876 |
(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
|
877 |
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
|
878 |
|
16562 | 879 |
|caughtException result| |
622 | 880 |
|
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
881 |
self handle:[:ex | |
20820 | 882 |
caughtException isNil ifTrue:[ |
883 |
caughtException := ex. |
|
884 |
]. |
|
885 |
ex proceedWith:nil |
|
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
886 |
] do:[ |
20820 | 887 |
result := aBlock value. |
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
888 |
]. |
16562 | 889 |
caughtException notNil ifTrue:[ |
20820 | 890 |
caughtException suspendedContext:thisContext. |
6429
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
891 |
|
20820 | 892 |
"/ the signal was raised during the execution of aBlock above. |
893 |
"/ Raise it now (delayed). |
|
894 |
caughtException raiseSignal |
|
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
895 |
]. |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
896 |
^ result |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
897 |
|
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
898 |
" |
6429
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
899 |
|s| |
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
900 |
|
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
901 |
s := Signal new mayProceed:true. |
d0a5a78e6227
better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents:
6396
diff
changeset
|
902 |
s deferAfter:[ |
20820 | 903 |
s raiseRequestWith:'hello' errorString:'eeee' |
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
904 |
] |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
905 |
" |
622 | 906 |
! |
907 |
||
12062 | 908 |
evaluate:aBlock ifRaised:exceptionValue |
909 |
"evaluate the argument, aBlock and return its value. |
|
910 |
If the receiver-signal is raised during evaluation, abort |
|
16562 | 911 |
the evaluation and return the value from exceptionValue. |
12062 | 912 |
This is similar to the catch & throw mechanism found in other languages" |
913 |
||
22496 | 914 |
^ self handle:exceptionValue do:aBlock. |
12062 | 915 |
|
916 |
" |
|
16562 | 917 |
Object messageNotUnderstoodSignal |
22496 | 918 |
evaluate:[ 123 size open ] |
919 |
ifRaised:[ self halt ] |
|
12062 | 920 |
" |
22496 | 921 |
|
922 |
"Modified: / 12-01-2018 / 17:46:55 / stefan" |
|
12062 | 923 |
! |
924 |
||
1 | 925 |
handle:handleBlock do:aBlock |
926 |
"evaluate the argument, aBlock. |
|
927 |
If the receiver-signal is raised during evaluation, |
|
928 |
evaluate the handleBlock passing it an Exception argument. |
|
929 |
The handler may decide how to react to the signal by sending |
|
930 |
a corresponding message to the exception (see there). |
|
931 |
If the signal is not raised, return the value of evaluating |
|
932 |
aBlock." |
|
933 |
||
4547
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
934 |
<context: #return> |
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
935 |
<exception: #handle> |
95 | 936 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
937 |
"/ thisContext markForHandle. -- same as above pragma |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
938 |
^ aBlock value "the real logic is in Exception>>doRaise" |
120 | 939 |
|
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 |
Object messageNotUnderstoodSignal handle:[:ex | |
16562 | 942 |
'oops' printNL. |
943 |
ex return |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
944 |
] do:[ |
16562 | 945 |
123 size open |
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
946 |
] |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
947 |
" |
95 | 948 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
949 |
" |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
950 |
|num| |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
951 |
|
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
952 |
num := 0. |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
953 |
Number divisionByZeroSignal handle:[:ex | |
16562 | 954 |
'oops' printNL. |
955 |
ex return |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
956 |
] do:[ |
16562 | 957 |
123 / num |
4491
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 |
" |
4438 | 960 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
961 |
"Modified: / 25.7.1999 / 19:43:01 / stefan" |
44 | 962 |
! |
963 |
||
362 | 964 |
handle:handleBlock from:anObject do:aBlock |
965 |
"evaluate the argument, aBlock. |
|
966 |
If the receiver-signal is raised during evaluation, |
|
967 |
and the exception originated from anObject, |
|
968 |
evaluate the handleBlock passing it an Exception argument. |
|
969 |
The handler may decide how to react to the signal by sending |
|
970 |
a corresponding message to the exception (see there). |
|
971 |
If the signal is not raised, return the value of evaluating |
|
972 |
aBlock." |
|
973 |
||
4547
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4540
diff
changeset
|
974 |
<context: #return> |
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
975 |
<exception: #handle> |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
976 |
|
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
977 |
"/ thisContext markForHandle. -- same as above pragma |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
978 |
^ aBlock value "the real logic is in Exception>>doRaise" |
362 | 979 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
980 |
" |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
981 |
the first open will be caught; the second not: |
362 | 982 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
983 |
|o1 o2| |
362 | 984 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
985 |
o1 := 123. |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
986 |
o2 := nil. |
16562 | 987 |
Object messageNotUnderstoodSignal |
988 |
handle: |
|
989 |
[:ex | |
|
990 |
'oops' printNL. |
|
991 |
ex proceed |
|
992 |
] |
|
993 |
from:o1 |
|
994 |
do: |
|
995 |
[ |
|
996 |
o1 open. |
|
997 |
o2 open |
|
998 |
] |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4486
diff
changeset
|
999 |
" |
4438 | 1000 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4440
diff
changeset
|
1001 |
"Modified: / 25.7.1999 / 19:43:40 / stefan" |
362 | 1002 |
! |
1003 |
||
419 | 1004 |
ignoreIn:aBlock |
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
1005 |
"evaluate the argument, aBlock. |
21855 | 1006 |
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
|
1007 |
This makes only sense for some signals, such as UserInterrupt |
21565 | 1008 |
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
|
1009 |
often leads to followup-errors." |
159 | 1010 |
|
21855 | 1011 |
^ self handle:[:ex | ex proceed] do:aBlock. |
159 | 1012 |
|
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
1013 |
" |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
1014 |
Object messageNotUnderstoodSignal ignoreIn:[ |
21565 | 1015 |
123 size open |
6396
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
1016 |
] |
74d5b0b588a6
added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents:
6200
diff
changeset
|
1017 |
" |
21565 | 1018 |
|
1019 |
"Modified (comment): / 24-02-2017 / 11:15:55 / stefan" |
|
21855 | 1020 |
"Modified (comment): / 20-06-2017 / 13:35:10 / cg" |
1 | 1021 |
! ! |
1022 |
||
2207 | 1023 |
!Signal class methodsFor:'documentation'! |
1249 | 1024 |
|
1025 |
version |
|
18726 | 1026 |
^ '$Header$' |
12062 | 1027 |
! |
1028 |
||
1029 |
version_CVS |
|
18726 | 1030 |
^ '$Header$' |
1249 | 1031 |
! ! |
18726 | 1032 |