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