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