author | Claus Gittinger <cg@exept.de> |
Sat, 31 Jul 1999 16:34:56 +0200 | |
changeset 4478 | 782108345281 |
parent 4476 | 696ac99f2a52 |
child 4480 | 9b7616845592 |
permissions | -rw-r--r-- |
1 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
171 | 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 |
" |
|
12 |
||
13 |
Object subclass:#Exception |
|
1118
1037616d9add
ignore unhandled querySignals
Claus Gittinger <cg@exept.de>
parents:
1038
diff
changeset
|
14 |
instanceVariableNames:'signal parameter errorString suspendedContext handlerContext |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
15 |
rejected originator resumeBlock rejectBlock proceedable |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
16 |
handlingSignal' |
1118
1037616d9add
ignore unhandled querySignals
Claus Gittinger <cg@exept.de>
parents:
1038
diff
changeset
|
17 |
classVariableNames:'EmergencyHandler RecursiveExceptionSignal' |
1037616d9add
ignore unhandled querySignals
Claus Gittinger <cg@exept.de>
parents:
1038
diff
changeset
|
18 |
poolDictionaries:'' |
1037616d9add
ignore unhandled querySignals
Claus Gittinger <cg@exept.de>
parents:
1038
diff
changeset
|
19 |
category:'Kernel-Exceptions' |
1 | 20 |
! |
21 |
||
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
22 |
Exception class instanceVariableNames:'NotifierString' |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
23 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
24 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
25 |
The following class instance variables are inherited by this class: |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
26 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
27 |
Object - |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
28 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
29 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
30 |
|
1953
c8a3af54acb3
unhandled querySignals should return nil
Claus Gittinger <cg@exept.de>
parents:
1710
diff
changeset
|
31 |
!Exception class methodsFor:'documentation'! |
12 | 32 |
|
88 | 33 |
copyright |
34 |
" |
|
35 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
171 | 36 |
All Rights Reserved |
88 | 37 |
|
38 |
This software is furnished under a license and may be used |
|
39 |
only in accordance with the terms of that license and with the |
|
40 |
inclusion of the above copyright notice. This software may not |
|
41 |
be provided or otherwise made available to, or used by, any |
|
42 |
other person. No title to or ownership of the software is |
|
43 |
hereby transferred. |
|
44 |
" |
|
45 |
! |
|
46 |
||
12 | 47 |
documentation |
48 |
" |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
49 |
Exception and its subclasses implement the same protocol as Signal. |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
50 |
So class based exceptions may be implemented as subclasses of Exception. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
51 |
|
68 | 52 |
Instances of Exception are passed to a Signal handling block as argument. |
53 |
The handler block may perform various actions by sending corresponding messages |
|
142 | 54 |
to the exception object. The following actions are possible: |
1 | 55 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
56 |
reject - don't handle this signal; |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
57 |
another handler will be searched for, |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
58 |
upper in the calling hierarchy |
1 | 59 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
60 |
proceed - return from the Signal>>raise, with nil as value |
142 | 61 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
62 |
proceedWith:val - same, but return val from Signal>>raise |
1 | 63 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
64 |
return - return from the Signal>>handle:do:, with nil as value |
142 | 65 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
66 |
returnWith:val - same, but return val from Signal>>handle:do: |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
67 |
(this is also the handlers default, |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
68 |
if it falls through; taking the handlerBlocks value |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
69 |
as return value) |
1 | 70 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
71 |
restart - restart the Signal>>handle:do:, after repairing |
1 | 72 |
|
142 | 73 |
Via the Exception object, the handler can also query the state of execution: |
68 | 74 |
where the Signal was raised, where the handler is, the signal which caused |
142 | 75 |
the error and the errorString passed when the signal was raised. Also, an optional |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
76 |
parameter can be passed - the use is signal specific. |
44 | 77 |
|
1274 | 78 |
[instance variables:] |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
79 |
signal <Signal> the signal which caused the exception |
142 | 80 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
81 |
parameter <Object> a parameter (if any) which was passed when raising |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
82 |
the signal (only if raised with #raiseWith:aParameter) |
142 | 83 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
84 |
errorString <String> an errorString |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
85 |
(usually the signals own errorString, but sometimes |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
86 |
changed explicitely in #raiseWith:errorString:) |
44 | 87 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
88 |
suspendedContext <Context> the context in which the raise occured |
142 | 89 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
90 |
handlerContext <Context> the context of the handler (if any) |
142 | 91 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
92 |
resumeBlock <Block> private to the exception; needed to perform resume action |
44 | 93 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
94 |
rejectBlock <Block> private to the exception; needed to perform reject action |
44 | 95 |
|
142 | 96 |
In case of an unhandled signal raise, Exceptions EmergenyHandler will be evaluated. |
68 | 97 |
The default emergeny handler will enter the debugger. |
142 | 98 |
|
68 | 99 |
For applications, which do not want Debuggers to come up, other handlers are |
100 |
possible. |
|
362 | 101 |
For example, to get the typical C++ behavior, use: |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
102 |
Exception emergencyHandler:[:ex | Smalltalk exitWithCoreDump] |
68 | 103 |
|
1274 | 104 |
|
105 |
[Class variables:] |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
106 |
EmergencyHandler <Block> this block is evaluated, if no handler was defined |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
107 |
for a signal (i.e. this one is responsible for the |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
108 |
unhandled exception debugger). |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
109 |
Having this being a block allows to globally catch |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
110 |
these errors - even when no enclosing handler-scope |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
111 |
around the erronous code exists. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
112 |
(as the catch/through does). |
171 | 113 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
114 |
RecursiveExceptionSignal |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
115 |
<Signal> raised when within a handler for some signal, |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
116 |
the same signal is raised again. |
1274 | 117 |
|
118 |
||
119 |
[see also:] |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
120 |
Signal SignalSet QuerySignal |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
121 |
Context Block |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
122 |
Object DebugView |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
123 |
(``Exception handling and signals'': programming/exceptions.html) |
1292 | 124 |
|
125 |
[author:] |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
126 |
Claus Gittinger |
12 | 127 |
" |
2174 | 128 |
! |
129 |
||
130 |
examples |
|
131 |
" |
|
132 |
Examples on Exception-raising & handling are found in the doc/coding |
|
133 |
section (CodingExamples). |
|
134 |
||
135 |
The emergencyHandler stuff is very useful, to prevent endUser applications |
|
136 |
from entering the debugger. |
|
137 |
Some commonly used (useful) emergency handlers are provided in the |
|
138 |
'useful handlers' section; try them to learn more |
|
139 |
(especially, the mailingHandler is fun). |
|
140 |
||
2219 | 141 |
Of course, these are only examples - you may define your own handler |
142 |
block and pass it to the #emergencyHandler: method. |
|
143 |
||
144 |
BTW: the Launchers 'source & debugger' settings menu allows you |
|
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
145 |
to install either a default or the notifying handler. |
2219 | 146 |
|
147 |
||
148 |
A handler which shows a box, then aborts - (no more debuggers): |
|
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
149 |
[exBegin] |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
150 |
Exception emergencyHandler:(Exception abortingEmergencyHandler) |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
151 |
[exEnd] |
2219 | 152 |
|
153 |
||
154 |
A handler which aborts - (no box, no debugger): |
|
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
155 |
[exBegin] |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
156 |
Exception emergencyHandler:[:ex | AbortSignal raise] |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
157 |
[exEnd] |
2174 | 158 |
|
159 |
||
160 |
try some exception (for demonstration, in some other process): |
|
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
161 |
[exBegin] |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
162 |
[ |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
163 |
#(1 2 3) at:4 |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
164 |
] fork. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
165 |
[exEnd] |
2174 | 166 |
|
2219 | 167 |
cleanup (switch back to the regular handler, which enters the debugger): |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
168 |
[exBegin] |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
169 |
Exception emergencyHandler:nil |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
170 |
[exEnd] |
2219 | 171 |
|
172 |
||
173 |
A handler which shows a warnBox and asks for debugging: |
|
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
174 |
[exBegin] |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
175 |
Exception emergencyHandler:(Exception notifyingEmergencyHandler) |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
176 |
[exEnd] |
2219 | 177 |
|
2174 | 178 |
|
179 |
||
180 |
A handler which dumps information to a file (watch the file 'errorTrace.stx'): |
|
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
181 |
[exBegin] |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
182 |
Exception emergencyHandler:(Exception dumpingEmergencyHandler) |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
183 |
[exEnd] |
2219 | 184 |
|
185 |
||
2174 | 186 |
|
187 |
A handler which sends you mail: |
|
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
188 |
[exBegin] |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
189 |
Exception emergencyHandler:(Exception mailingEmergencyHandler) |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
190 |
[exEnd] |
2174 | 191 |
" |
12 | 192 |
! ! |
3 | 193 |
|
1953
c8a3af54acb3
unhandled querySignals should return nil
Claus Gittinger <cg@exept.de>
parents:
1710
diff
changeset
|
194 |
!Exception class methodsFor:'initialization'! |
171 | 195 |
|
196 |
initialize |
|
197 |
"setup the signal used to handle unhandled signals" |
|
198 |
||
199 |
RecursiveExceptionSignal isNil ifTrue:[ |
|
302 | 200 |
RecursiveExceptionSignal := ErrorSignal newSignalMayProceed:false. |
171 | 201 |
RecursiveExceptionSignal nameClass:self message:#recursiveExceptionSignal. |
202 |
RecursiveExceptionSignal notifierString:'recursive signal raise in handler' |
|
203 |
] |
|
204 |
! ! |
|
205 |
||
1953
c8a3af54acb3
unhandled querySignals should return nil
Claus Gittinger <cg@exept.de>
parents:
1710
diff
changeset
|
206 |
!Exception class methodsFor:'instance creation'! |
621 | 207 |
|
4441 | 208 |
signal:aSignal originator:origin |
209 |
"create a new instance and set the fields in preparation for a raise. |
|
210 |
- only to be sent from the signal when raising" |
|
211 |
||
212 |
"{ Pragma: +inlineNew }" |
|
213 |
||
214 |
^ (self basicNew) signal:aSignal originator:origin. |
|
215 |
||
216 |
"Created: / 23.7.1999 / 13:40:45 / stefan" |
|
217 |
! |
|
218 |
||
621 | 219 |
signal:aSignal parameter:aParameter errorString:aString suspendedContext:sContext originator:origin |
220 |
"create a new instance and set the fields in preparation for a raise. |
|
221 |
- only to be sent from the signal when raising" |
|
222 |
||
3091 | 223 |
"{ Pragma: +inlineNew }" |
224 |
||
3017 | 225 |
^ (self basicNew) |
621 | 226 |
signal:aSignal |
227 |
parameter:aParameter |
|
228 |
errorString:aString |
|
229 |
suspendedContext:sContext |
|
230 |
originator:origin. |
|
231 |
! ! |
|
232 |
||
1953
c8a3af54acb3
unhandled querySignals should return nil
Claus Gittinger <cg@exept.de>
parents:
1710
diff
changeset
|
233 |
!Exception class methodsFor:'Signal constants'! |
171 | 234 |
|
235 |
recursiveExceptionSignal |
|
236 |
"return the signal used to handle recursive signals in the handlers" |
|
237 |
||
238 |
^ RecursiveExceptionSignal |
|
239 |
! ! |
|
240 |
||
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
241 |
!Exception class methodsFor:'compatibility - accessing'! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
242 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
243 |
errorString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
244 |
"return the notifier string. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
245 |
If the notifier string starts with space, prepend |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
246 |
the parents notifier string" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
247 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
248 |
NotifierString isNil ifTrue:[ |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
249 |
^ self parent errorString |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
250 |
] ifFalse:[ |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
251 |
(NotifierString size > 0 |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
252 |
and:[NotifierString first == (Character space)]) ifTrue:[ |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
253 |
^ self parent errorString, NotifierString |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
254 |
] ifFalse:[ |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
255 |
^ NotifierString |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
256 |
]. |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
257 |
] |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
258 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
259 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
260 |
Object errorSignal errorString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
261 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
262 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
263 |
"Created: / 23.7.1999 / 14:22:25 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
264 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
265 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
266 |
errorStringExtra:extraString with:aParameter |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
267 |
"used when raising with a given error string and/or parameter; |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
268 |
if the errorString starts with a space, it is appended to the receivers |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
269 |
notifier string; if it ends with a space, it is prepended. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
270 |
Otherwise, the extraString is returned. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
271 |
If no extraString is given, use the signals default errorString." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
272 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
273 |
|t| |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
274 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
275 |
(self inheritsFrom:Object userNotificationSignal) ifTrue:[ |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
276 |
"/ all userNotifications pass the extraString unchanged. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
277 |
^ extraString |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
278 |
]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
279 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
280 |
extraString isNil ifTrue:[ |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
281 |
t := self errorString |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
282 |
] ifFalse:[ |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
283 |
t := extraString. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
284 |
(extraString endsWith:Character space) ifTrue:[ |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
285 |
t := extraString, self errorString |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
286 |
] ifFalse:[ |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
287 |
(extraString startsWith:Character space) ifTrue:[ |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
288 |
t := self errorString, extraString |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
289 |
] |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
290 |
]. |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
291 |
]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
292 |
^ t. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
293 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
294 |
"/ aParameter isNil ifTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
295 |
"/ ^ t |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
296 |
"/ ]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
297 |
"/ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
298 |
"/ (t startsWith:' ') ifTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
299 |
"/ ^ aParameter printString , t |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
300 |
"/ ]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
301 |
"/ (t endsWith:' ') ifTrue:[ |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
302 |
"/ ^ t , aParameter printString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
303 |
"/ ]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
304 |
"/ ^ t |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
305 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
306 |
"Modified: / 25.3.1997 / 12:12:37 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
307 |
"Created: / 23.7.1999 / 14:23:38 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
308 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
309 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
310 |
handlerBlock |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
311 |
"Compatibility with Signal. Class based exeptions do not have a handler |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
312 |
block. They redefine the #action method instead" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
313 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
314 |
^ nil |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
315 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
316 |
"Created: / 23.7.1999 / 14:43:18 / stefan" |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
317 |
"Modified: / 24.7.1999 / 20:52:10 / stefan" |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
318 |
! ! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
319 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
320 |
!Exception class methodsFor:'compatibility - queries'! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
321 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
322 |
accepts:aSignal |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
323 |
"return true, if the receiver accepts the argument, aSignal. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
324 |
(i.e. the receiver is aSignal or a parent of it). False otherwise." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
325 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
326 |
|s| |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
327 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
328 |
aSignal isQuerySignal ifTrue:[^ false]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
329 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
330 |
s := aSignal. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
331 |
[s notNil] whileTrue:[ |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
332 |
self == s ifTrue:[^ true]. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
333 |
s := s parent |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
334 |
]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
335 |
^ false |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
336 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
337 |
"Created: / 23.7.1999 / 14:00:47 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
338 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
339 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
340 |
handlerForSignal:signal context:theContext originator:originator |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
341 |
"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:
4449
diff
changeset
|
342 |
The block is retrieved from aContext. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
343 |
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:
4449
diff
changeset
|
344 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
345 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
346 |
(theContext selector ~~ #'handle:from:do:' |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
347 |
or:[(theContext argAt:2) == originator]) ifTrue:[ |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
348 |
(self accepts:signal) ifTrue:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
349 |
^ theContext argAt:1 |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
350 |
] |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
351 |
]. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
352 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
353 |
^ nil |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
354 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
355 |
"Created: / 25.7.1999 / 19:52:58 / stefan" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
356 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
357 |
|
4476 | 358 |
handlingExceptionInContext:theContext |
359 |
"answer the handling exception from aContext." |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
360 |
|
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
361 |
(theContext selector == #'handle:from:do:' |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
362 |
or:[theContext selector == #'handle:do:']) ifTrue:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
363 |
^ theContext receiver |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
364 |
]. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
365 |
|
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
366 |
^ nil |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
367 |
! |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
368 |
|
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
369 |
inheritsFrom:anotherSignal |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
370 |
"return true, if the receiver is a child of anotherSignal |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
371 |
(i.e. if handling anotherSignal also handles the receiver) |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
372 |
This is almost the same as accepts, but returns false, if |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
373 |
the receiver is identical to anotherSignal." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
374 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
375 |
self == anotherSignal ifTrue:[^ false]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
376 |
^ anotherSignal accepts:self |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
377 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
378 |
"Created: / 23.7.1999 / 13:59:51 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
379 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
380 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
381 |
isHandled |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
382 |
"return true, if there is a handler for the receiver signal. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
383 |
Raising an unhandled signal will usually lead into the debugger, |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
384 |
but can be caught globally by setting Exceptions EmergencyHandler." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
385 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
386 |
^ self isHandledIn:(thisContext sender). |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
387 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
388 |
"Created: / 23.7.1999 / 14:03:50 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
389 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
390 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
391 |
isHandledIn:aContext |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
392 |
"return true, if there is a handler for the receiver signal in the |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
393 |
contextChain starting with aContext." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
394 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
395 |
|con r| |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
396 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
397 |
con := aContext. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
398 |
[con notNil] whileTrue:[ |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
399 |
con := con findSpecialHandle:true raise:false. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
400 |
con notNil ifTrue:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
401 |
((r := con receiver) notNil |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
402 |
and:[(r handlerForSignal:self context:con originator:nil) notNil] |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
403 |
) ifTrue:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
404 |
"found a handler context" |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
405 |
^ true |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
406 |
] |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
407 |
] |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
408 |
]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
409 |
^ false |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
410 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
411 |
"Created: / 23.7.1999 / 14:03:34 / stefan" |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
412 |
"Modified: / 25.7.1999 / 22:59:03 / stefan" |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
413 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
414 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
415 |
isQuerySignal |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
416 |
"return true, if this is a querySignal - always return false here" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
417 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
418 |
^ false |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
419 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
420 |
"Created: / 23.7.1999 / 13:50:16 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
421 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
422 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
423 |
isSignal |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
424 |
"return true, if the receiver is some kind of signal; |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
425 |
true returned here - the method is redefined from Object." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
426 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
427 |
^ true |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
428 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
429 |
"Created: / 23.7.1999 / 13:49:59 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
430 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
431 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
432 |
mayProceed |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
433 |
"return true, if the exception handler is allowed to proceed |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
434 |
the execution where the exception occured. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
435 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
436 |
Subclasses may redefine this." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
437 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
438 |
^ true |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
439 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
440 |
"Modified: / 23.7.1999 / 14:50:11 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
441 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
442 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
443 |
parent |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
444 |
"return the parent Signal/Exception of myself. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
445 |
Subclasses may redefine this to install themself as child of |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
446 |
existing Signals." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
447 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
448 |
self == Exception ifTrue:[ |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
449 |
^ nil |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
450 |
]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
451 |
|
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
452 |
^ self superclass |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
453 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
454 |
"Created: / 23.7.1999 / 14:01:29 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
455 |
"Modified: / 23.7.1999 / 16:15:38 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
456 |
! ! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
457 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
458 |
!Exception class methodsFor:'compatibility - raising'! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
459 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
460 |
new |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
461 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
462 |
^ self basicNew signal:self. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
463 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
464 |
"Modified: / 23.7.1999 / 13:53:12 / stefan" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
465 |
"Created: / 24.7.1999 / 13:21:13 / stefan" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
466 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
467 |
|
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
468 |
newException |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
469 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
470 |
^ self new |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
471 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
472 |
"Created: / 23.7.1999 / 13:45:49 / stefan" |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
473 |
"Modified: / 24.7.1999 / 13:21:25 / stefan" |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
474 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
475 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
476 |
newExceptionFrom:originator |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
477 |
"answer a new exception object for this signal. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
478 |
Set the originator. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
479 |
Subclasses may redefine this method" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
480 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
481 |
^ self new originator:originator |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
482 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
483 |
"Created: / 23.7.1999 / 13:47:07 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
484 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
485 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
486 |
raise |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
487 |
"raise a signal nonproceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
488 |
The signals notifierString is used as errorString." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
489 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
490 |
^ self newException raise |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
491 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
492 |
"Modified: / 2.5.1996 / 16:36:23 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
493 |
"Modified: / 5.3.1998 / 16:44:36 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
494 |
"Created: / 23.7.1999 / 14:07:17 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
495 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
496 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
497 |
raiseErrorString:aString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
498 |
"raise a signal nonproceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
499 |
The argument is used as errorString." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
500 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
501 |
^ (self newException errorString:aString) raise. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
502 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
503 |
"Modified: / 9.5.1996 / 15:17:59 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
504 |
"Modified: / 12.3.1998 / 15:15:22 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
505 |
"Created: / 23.7.1999 / 14:07:33 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
506 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
507 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
508 |
raiseErrorString:aString in:aContext |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
509 |
"raise a signal nonproceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
510 |
The argument is used as errorString. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
511 |
The additional context is passed as the context responsible for the raise, |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
512 |
allowing a raise to mimicri the exception happened somewhere else." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
513 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
514 |
^ (self newException |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
515 |
signal:self |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
516 |
parameter:nil |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
517 |
errorString:aString |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
518 |
suspendedContext:aContext |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
519 |
originator:nil) raise. |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
520 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
521 |
"Modified: / 26.7.1996 / 16:42:47 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
522 |
"Modified: / 12.3.1998 / 15:43:43 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
523 |
"Created: / 23.7.1999 / 14:07:48 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
524 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
525 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
526 |
raiseFrom:something |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
527 |
"raise a signal nonproceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
528 |
The argument, something is passed both as parameter and originator." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
529 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
530 |
^ ((self newExceptionFrom:something) parameter:something) raise |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
531 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
532 |
"Modified: / 2.5.1996 / 16:36:38 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
533 |
"Modified: / 5.3.1998 / 16:49:55 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
534 |
"Created: / 23.7.1999 / 14:07:59 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
535 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
536 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
537 |
raiseIn:aContext |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
538 |
"raise a signal nonproceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
539 |
The signals notifierString is used as errorString. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
540 |
The additional context is passed as the context responsible for the raise, |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
541 |
allowing a raise to mimicri the exception happened somewhere else." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
542 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
543 |
^ (self newException suspendedContext:aContext) raise. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
544 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
545 |
"Modified: / 2.5.1996 / 16:36:44 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
546 |
"Modified: / 5.3.1998 / 16:50:21 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
547 |
"Created: / 23.7.1999 / 14:08:13 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
548 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
549 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
550 |
raiseRequest |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
551 |
"raise a signal proceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
552 |
The signals notifierString is used as errorString." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
553 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
554 |
^ self newException raiseRequest. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
555 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
556 |
"Modified: / 2.5.1996 / 16:36:52 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
557 |
"Modified: / 5.3.1998 / 16:50:46 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
558 |
"Created: / 23.7.1999 / 14:08:24 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
559 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
560 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
561 |
raiseRequestFrom:something |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
562 |
"raise a signal proceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
563 |
The argument, something is passed both as parameter and originator." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
564 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
565 |
^ ((self newExceptionFrom:something) parameter:something) raiseRequest. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
566 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
567 |
"Modified: / 2.5.1996 / 16:36:38 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
568 |
"Modified: / 5.3.1998 / 16:52:46 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
569 |
"Created: / 23.7.1999 / 14:08:36 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
570 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
571 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
572 |
raiseRequestWith:aParameter |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
573 |
"raise a signal proceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
574 |
The signals notifierString is used as errorString." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
575 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
576 |
^ (self newException parameter:aParameter) raiseRequest. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
577 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
578 |
"Modified: / 9.5.1996 / 15:13:20 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
579 |
"Modified: / 12.3.1998 / 15:16:57 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
580 |
"Created: / 23.7.1999 / 14:08:48 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
581 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
582 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
583 |
raiseRequestWith:aParameter errorString:aString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
584 |
"raise a signal proceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
585 |
The argument, aString is used as errorString." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
586 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
587 |
^ (self newException |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
588 |
parameter:aParameter; |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
589 |
errorString:aString |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
590 |
) raiseRequest |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
591 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
592 |
"Modified: / 9.5.1996 / 15:13:35 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
593 |
"Modified: / 12.3.1998 / 15:17:52 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
594 |
"Created: / 23.7.1999 / 14:08:57 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
595 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
596 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
597 |
raiseRequestWith:aParameter errorString:aString in:aContext |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
598 |
"raise a signal proceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
599 |
The argument, aString is used as errorString. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
600 |
The additional context is passed as the context responsible for the raise, |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
601 |
allowing a raise to mimicri the exception happened somewhere else." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
602 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
603 |
^ (self newException |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
604 |
parameter:aParameter; |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
605 |
errorString:aString; |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
606 |
suspendedContext:aContext) raiseRequest |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
607 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
608 |
"Modified: / 26.7.1996 / 16:29:27 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
609 |
"Modified: / 12.3.1998 / 15:18:34 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
610 |
"Created: / 23.7.1999 / 14:09:07 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
611 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
612 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
613 |
raiseRequestWith:aParameter in:aContext |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
614 |
"raise a signal proceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
615 |
The signals notifierString is used as errorString. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
616 |
The additional context is passed as the context responsible for the raise, |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
617 |
allowing a raise to mimicri the exception happened somewhere else." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
618 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
619 |
^ (self newException |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
620 |
parameter:aParameter; |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
621 |
suspendedContext:aContext) raiseRequest. |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
622 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
623 |
"Modified: / 26.7.1996 / 16:29:33 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
624 |
"Modified: / 12.3.1998 / 15:18:55 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
625 |
"Created: / 23.7.1999 / 14:09:17 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
626 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
627 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
628 |
raiseWith:aParameter |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
629 |
"raise a signal nonproceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
630 |
The argument, aParameter is passed as parameter." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
631 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
632 |
^ (self newException parameter:aParameter) raise. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
633 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
634 |
"Modified: / 9.5.1996 / 15:14:24 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
635 |
"Modified: / 12.3.1998 / 15:19:11 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
636 |
"Created: / 23.7.1999 / 14:09:27 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
637 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
638 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
639 |
raiseWith:aParameter errorString:aString |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
640 |
"raise a signal nonproceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
641 |
The argument, aString is used as errorString, aParameter is passed |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
642 |
as exception parameter." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
643 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
644 |
^ (self newException |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
645 |
parameter:aParameter; |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
646 |
errorString:aString) raise. |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
647 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
648 |
"Modified: / 9.5.1996 / 15:14:32 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
649 |
"Modified: / 12.3.1998 / 15:19:40 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
650 |
"Created: / 23.7.1999 / 14:09:36 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
651 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
652 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
653 |
raiseWith:aParameter errorString:aString in:aContext |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
654 |
"raise a signal nonproceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
655 |
The argument, aString is used as errorString, aParameter is passed |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
656 |
as exception parameter. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
657 |
The additional context is passed as the context responsible for the raise, |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
658 |
allowing a raise to mimicri the exception happened somewhere else." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
659 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
660 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
661 |
^ (self newException |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
662 |
parameter:aParameter; |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
663 |
errorString:aString; |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
664 |
suspendedContext:aContext) raise. |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
665 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
666 |
"Modified: / 26.7.1996 / 16:29:42 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
667 |
"Modified: / 12.3.1998 / 15:20:12 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
668 |
"Created: / 23.7.1999 / 14:09:46 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
669 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
670 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
671 |
raiseWith:aParameter in:aContext |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
672 |
"raise a signal nonproceedable. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
673 |
The argument, aParameter is passed as parameter." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
674 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
675 |
^ (self newException parameter:aParameter; |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
676 |
suspendedContext:aContext) raise. |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
677 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
678 |
"Modified: / 9.5.1996 / 15:14:24 / cg" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
679 |
"Modified: / 12.3.1998 / 15:34:51 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
680 |
"Created: / 23.7.1999 / 14:10:04 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
681 |
! ! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
682 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
683 |
!Exception class methodsFor:'compatibility - save evaluation'! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
684 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
685 |
catch:aBlock |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
686 |
"evaluate the argument, aBlock. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
687 |
If the receiver-signal is raised during evaluation, abort |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
688 |
the evaluation and return true; otherwise return false. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
689 |
This is the catch & throw mechanism found in other languages, |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
690 |
where the returned value indicates if an exception occured." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
691 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
692 |
|raiseOccurred| |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
693 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
694 |
raiseOccurred := false. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
695 |
self handle:[:ex | raiseOccurred := true. ex return] do:aBlock. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
696 |
^ raiseOccurred |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
697 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
698 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
699 |
Object messageNotUnderstoodSignal catch:[ |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
700 |
123 size open |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
701 |
] |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
702 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
703 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
704 |
"Created: / 23.7.1999 / 14:06:01 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
705 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
706 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
707 |
handle:handleBlock do:aBlock |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
708 |
"evaluate the argument, aBlock. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
709 |
If the receiver-signal is raised during evaluation, |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
710 |
evaluate the handleBlock passing it an Exception argument. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
711 |
The handler may decide how to react to the signal by sending |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
712 |
a corresponding message to the exception (see there). |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
713 |
If the signal is not raised, return the value of evaluating |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
714 |
aBlock." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
715 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
716 |
thisContext markForHandle. |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
717 |
^ aBlock value "the real logic is in Exception>>doRaise" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
718 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
719 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
720 |
Object messageNotUnderstoodSignal handle:[:ex | |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
721 |
'oops' printNL. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
722 |
ex return |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
723 |
] do:[ |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
724 |
123 size open |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
725 |
] |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
726 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
727 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
728 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
729 |
|num| |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
730 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
731 |
num := 0. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
732 |
Number divisionByZeroSignal handle:[:ex | |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
733 |
'oops' printNL. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
734 |
ex return |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
735 |
] do:[ |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
736 |
123 / num |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
737 |
] |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
738 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
739 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
740 |
"Created: / 23.7.1999 / 14:06:13 / stefan" |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
741 |
"Modified: / 25.7.1999 / 19:44:05 / stefan" |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
742 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
743 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
744 |
handle:handleBlock from:anObject do:aBlock |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
745 |
"evaluate the argument, aBlock. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
746 |
If the receiver-signal is raised during evaluation, |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
747 |
and the exception originated from anObject, |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
748 |
evaluate the handleBlock passing it an Exception argument. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
749 |
The handler may decide how to react to the signal by sending |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
750 |
a corresponding message to the exception (see there). |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
751 |
If the signal is not raised, return the value of evaluating |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
752 |
aBlock." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
753 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
754 |
thisContext markForHandle. |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
755 |
^ aBlock value "the real logic is in Exception>>doRaise" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
756 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
757 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
758 |
the first open will be caught; the second not: |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
759 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
760 |
|o1 o2| |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
761 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
762 |
o1 := 123. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
763 |
o2 := nil. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
764 |
Object messageNotUnderstoodSignal |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
765 |
handle: |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
766 |
[:ex | |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
767 |
'oops' printNL. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
768 |
ex proceed |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
769 |
] |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
770 |
from:o1 |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
771 |
do: |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
772 |
[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
773 |
o1 open. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
774 |
o2 open |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
775 |
] |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
776 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
777 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
778 |
"Created: / 23.7.1999 / 14:06:26 / stefan" |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
779 |
"Modified: / 25.7.1999 / 19:44:13 / stefan" |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
780 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
781 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
782 |
ignoreIn:aBlock |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
783 |
"evaluate the argument, aBlock. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
784 |
Ignore the receiver-signal during evaluation - i.e. simply |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
785 |
continue. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
786 |
This makes only sense for some signals, such as UserInterrupt |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
787 |
or AbortSignal, because continuing after an exception without any cleanup |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
788 |
often leads to followup-errors." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
789 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
790 |
^ self handle:[:ex | ex proceed] do:aBlock. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
791 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
792 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
793 |
Object messageNotUnderstoodSignal ignoreIn:[ |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
794 |
123 size open |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
795 |
] |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
796 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
797 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
798 |
"Created: / 23.7.1999 / 14:06:40 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
799 |
! ! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
800 |
|
4447 | 801 |
!Exception class methodsFor:'compatibility - signal creation'! |
802 |
||
803 |
newSignal |
|
804 |
"create a new signal, using the receiver as a prototype and |
|
805 |
setting the parent of the new signal to the receiver." |
|
806 |
||
807 |
^ self newSignalMayProceed:self mayProceed |
|
808 |
||
809 |
"Created: / 23.7.1999 / 20:13:23 / stefan" |
|
810 |
! |
|
811 |
||
812 |
newSignalMayProceed:proceed |
|
813 |
"create a new signal, using the receiver as a prototype and |
|
814 |
setting the parent of the new signal to the receiver." |
|
815 |
||
816 |
^ (Signal basicNew) mayProceed:proceed; |
|
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
817 |
notifierString:NotifierString; |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
818 |
parent:self |
4447 | 819 |
|
820 |
"Created: / 23.7.1999 / 20:12:43 / stefan" |
|
821 |
! ! |
|
822 |
||
1953
c8a3af54acb3
unhandled querySignals should return nil
Claus Gittinger <cg@exept.de>
parents:
1710
diff
changeset
|
823 |
!Exception class methodsFor:'defaults'! |
12 | 824 |
|
825 |
emergencyHandler |
|
2174 | 826 |
"return the handler used for unhandled exceptions. |
827 |
||
828 |
If no EmergencyHandler has been set, a handler which enters the |
|
829 |
debugger is returned. |
|
830 |
The debugger is opened by asking the signal for a debug action, |
|
831 |
this allows to provide other debuggers in specialized (subclass-instances) |
|
832 |
of Signal (if that is ever needed)" |
|
12 | 833 |
|
77 | 834 |
" |
835 |
set it up, when called the first time |
|
836 |
" |
|
837 |
EmergencyHandler isNil ifTrue:[ |
|
2208 | 838 |
EmergencyHandler := [:ex | |
839 |
" |
|
840 |
sending it to the signal allows per-signal specific |
|
841 |
debuggers to be implemented in the future |
|
842 |
(for example, segv in primitive code could show things |
|
843 |
on the C-level ..) |
|
844 |
" |
|
845 |
(ex signal) enterDebuggerWith:ex message:(ex errorString). |
|
846 |
] |
|
77 | 847 |
]. |
848 |
||
12 | 849 |
^ EmergencyHandler |
2174 | 850 |
|
851 |
"Modified: 15.1.1997 / 20:50:37 / cg" |
|
12 | 852 |
! |
853 |
||
130 | 854 |
emergencyHandler:aOneArgBlock |
2174 | 855 |
"set the handler used for unhandled exceptions. |
856 |
The default (a nil-handler) leads to a debugger to be shown." |
|
12 | 857 |
|
130 | 858 |
EmergencyHandler := aOneArgBlock |
362 | 859 |
|
860 |
"ST-80 behavior of first showing a notifier: |
|
861 |
(I prefer to get right into the debugger, though) |
|
862 |
||
863 |
Exception |
|
2208 | 864 |
emergencyHandler: |
865 |
[:ex | self errorNotify:ex errorString ] |
|
2081 | 866 |
" |
867 |
||
868 |
"ST-X behavior of going right into the debugger: |
|
869 |
||
870 |
Exception |
|
2208 | 871 |
emergencyHandler:nil |
362 | 872 |
" |
873 |
||
874 |
"automatically aborting current operation, on error: |
|
875 |
(may be useful for end-user apps; make certain, |
|
876 |
you have abortSignal handlers at appropriate places) |
|
877 |
||
878 |
Exception |
|
2208 | 879 |
emergencyHandler: |
880 |
[:ex | Object abortSignal raise. ex return. ] |
|
362 | 881 |
" |
882 |
||
883 |
"finally, traditional language system behavior; dump core ;-) |
|
884 |
||
885 |
Exception |
|
2208 | 886 |
emergencyHandler: |
887 |
[:ex | Smalltalk exitWithCoreDump. ] |
|
362 | 888 |
" |
2081 | 889 |
|
2174 | 890 |
"Modified: 15.1.1997 / 20:49:06 / cg" |
891 |
! ! |
|
892 |
||
893 |
!Exception class methodsFor:'useful handlers'! |
|
894 |
||
895 |
abortingEmergencyHandler |
|
896 |
"return a block (usable as an emergency handler), |
|
897 |
which aborts after showing a warnBox. |
|
898 |
This is useful for endUser applications" |
|
899 |
||
900 |
^ [:ex | self warn:'Error: ' , ex errorString. |
|
2208 | 901 |
AbortSignal raise |
2174 | 902 |
] |
903 |
||
904 |
"test with (try a few halts or CTRL-C's): |
|
905 |
Exception emergencyHandler:(Exception abortingEmergencyHandler) |
|
906 |
" |
|
907 |
||
908 |
"back with: |
|
909 |
Exception emergencyHandler:(Exception notifyingEmergencyHandler) |
|
910 |
Exception emergencyHandler:nil |
|
911 |
" |
|
912 |
||
913 |
"Created: 15.1.1997 / 20:13:06 / cg" |
|
914 |
"Modified: 15.1.1997 / 20:15:02 / cg" |
|
915 |
! |
|
916 |
||
917 |
dumpingEmergencyHandler |
|
918 |
"return a block (usable as an emergency handler), |
|
919 |
which dumps the stackBacktrace to a trace file and |
|
920 |
aborts after showing a warnBox. |
|
921 |
This is useful, for endUser application, which are still being |
|
922 |
debugged (i.e. the programmers may have a look at the traceFile |
|
923 |
from time to time). |
|
924 |
||
925 |
Notice: |
|
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
926 |
The code below is just an example; you may want to change the |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
927 |
name of the error-file in your application |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
928 |
(but please: copy the code; do not modify here)" |
2174 | 929 |
|
930 |
^ [:ex | |
|
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
931 |
|str printedException| |
2174 | 932 |
|
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
933 |
ex signal == Signal noHandlerSignal ifTrue:[ |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
934 |
printedException := ex parameter. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
935 |
] ifFalse:[ |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
936 |
printedException := ex |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
937 |
]. |
2257 | 938 |
|
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
939 |
"/ user interruption is handled specially: |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
940 |
"/ allow user to choose between proceeding or aborting |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
941 |
"/ but never dump that information to the file. |
2174 | 942 |
|
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
943 |
printedException signal == Object userInterruptSignal ifTrue:[ |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
944 |
(self confirm:'abort current action ?') ifTrue:[ |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
945 |
AbortSignal raise |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
946 |
]. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
947 |
ex proceed |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
948 |
]. |
2174 | 949 |
|
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
950 |
"/ |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
951 |
"/ dump it to 'errorTrace.stx' |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
952 |
"/ |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
953 |
str := 'errorTrace.stx' asFilename appendingWriteStream. |
2174 | 954 |
|
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
955 |
str nextPutLine:('******************************* ' |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
956 |
, AbsoluteTime now printString |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
957 |
, ' *******************************'). |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
958 |
str cr. |
2174 | 959 |
|
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
960 |
str nextPutLine:('** Error: ' , printedException errorString). |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
961 |
str nextPutLine:('** Signal: ' , printedException signal printString). |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
962 |
str nextPutLine:('** Parameter: ' , printedException parameter printString). |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
963 |
str nextPutLine:('** Process: ' , Processor activeProcess printString). |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
964 |
str nextPutLine:('** Backtrace:'). |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
965 |
str cr. |
2174 | 966 |
|
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
967 |
printedException suspendedContext fullPrintAllOn:str. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
968 |
str cr. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
969 |
str cr. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
970 |
str close. |
2174 | 971 |
|
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
972 |
"/ send a line to stdErr |
2257 | 973 |
|
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
974 |
('[warning]: ignored error: ' , printedException errorString) errorPrintCR. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
975 |
('[warning]: error information appended to ''errorTrace.stx''') errorPrintCR. |
2257 | 976 |
|
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
977 |
AbortSignal raise |
2174 | 978 |
] |
979 |
||
980 |
"test with (try a few halts or CTRL-C's): |
|
981 |
Exception emergencyHandler:(Exception dumpingEmergencyHandler) |
|
982 |
" |
|
983 |
||
984 |
"back with: |
|
985 |
Exception emergencyHandler:(Exception notifyingEmergencyHandler) |
|
986 |
Exception emergencyHandler:nil |
|
987 |
" |
|
988 |
||
989 |
"Created: 15.1.1997 / 20:14:52 / cg" |
|
2257 | 990 |
"Modified: 24.1.1997 / 20:36:21 / cg" |
2174 | 991 |
! |
992 |
||
993 |
mailingEmergencyHandler |
|
994 |
"return a block (usable as an emergency handler), |
|
995 |
which shows a warnBox and optionally mails a stackBacktrace to a maintainer. |
|
996 |
This is useful, for endUser application, which are still being |
|
997 |
debugged (i.e. the programmers may have a look at the errors). |
|
998 |
||
999 |
Notice: the stuff here is a demonstration only; it should be modified |
|
2208 | 1000 |
for your particular environment ... |
1001 |
... but please: copy the code and modify there; |
|
1002 |
leave the stuff below as it is." |
|
2174 | 1003 |
|
1004 |
^ [:ex | |
|
2208 | 1005 |
|str printedException doMail emergencyMailReceiver pipe| |
2174 | 1006 |
|
2208 | 1007 |
ex signal == Signal noHandlerSignal ifTrue:[ |
1008 |
printedException := ex parameter. |
|
1009 |
] ifFalse:[ |
|
1010 |
printedException := ex |
|
1011 |
]. |
|
2174 | 1012 |
|
2208 | 1013 |
"/ user interruption is handled specially: |
1014 |
"/ allow user to choose between proceeding or aborting |
|
1015 |
"/ but never dump that information to the file. |
|
2174 | 1016 |
|
2208 | 1017 |
printedException signal == Object userInterruptSignal ifTrue:[ |
1018 |
(self confirm:'abort current action ?') ifTrue:[ |
|
1019 |
AbortSignal raise |
|
1020 |
]. |
|
1021 |
ex proceed |
|
1022 |
]. |
|
2174 | 1023 |
|
2208 | 1024 |
"/ somehow get the name of the guy to receive the mail |
1025 |
"/ you have to implement that yourself. |
|
2174 | 1026 |
|
2208 | 1027 |
"/ emergencyMailReceiver := OneOfYourClass getEmergencyMailReceiver. |
1028 |
emergencyMailReceiver := OperatingSystem getLoginName. |
|
2174 | 1029 |
|
2208 | 1030 |
emergencyMailReceiver isNil ifTrue:[ |
1031 |
self warn:(printedException errorString |
|
1032 |
, '\\No mailing to service people possible.') withCRs. |
|
1033 |
doMail := false. |
|
1034 |
] ifFalse:[ |
|
1035 |
doMail := self confirm:(printedException errorString |
|
1036 |
, '\\Mail error information to the service people (' |
|
1037 |
, emergencyMailReceiver , ') ?') withCRs |
|
1038 |
]. |
|
1039 |
doMail ifTrue:[ |
|
1040 |
str := '' writeStream. |
|
2174 | 1041 |
|
2208 | 1042 |
str nextPutLine:('Error notification from ' |
1043 |
, OperatingSystem getLoginName |
|
1044 |
, '@' |
|
1045 |
, OperatingSystem getHostName). |
|
1046 |
str cr. |
|
2174 | 1047 |
|
2208 | 1048 |
str nextPutLine:('Time: ' , AbsoluteTime now printString). |
1049 |
str nextPutLine:('Error: ', printedException errorString). |
|
1050 |
str nextPutLine:('Signal: ', printedException signal printString). |
|
1051 |
str nextPutLine:('Parameter: ', printedException parameter printString). |
|
1052 |
str nextPutLine:('Process: ', Processor activeProcess printString). |
|
1053 |
str nextPutLine:'Backtrace:'. |
|
1054 |
str cr. |
|
2174 | 1055 |
|
2208 | 1056 |
printedException suspendedContext fullPrintAllOn:str. |
1057 |
str cr;cr. |
|
2174 | 1058 |
|
2208 | 1059 |
str close. |
2174 | 1060 |
|
2208 | 1061 |
pipe := PipeStream |
1062 |
writingTo:'mail ', emergencyMailReceiver. |
|
1063 |
pipe notNil ifTrue:[ |
|
1064 |
pipe nextPutLine:'Subject: automatic error report'. |
|
1065 |
pipe nextPutAll:str contents. |
|
1066 |
pipe cr. |
|
1067 |
pipe close. |
|
1068 |
] |
|
1069 |
]. |
|
2174 | 1070 |
|
2208 | 1071 |
AbortSignal raise |
2174 | 1072 |
] |
1073 |
||
1074 |
"test with (try a few halts or CTRL-C's): |
|
1075 |
Exception emergencyHandler:(Exception mailingEmergencyHandler) |
|
1076 |
" |
|
1077 |
||
1078 |
"back with: |
|
1079 |
Exception emergencyHandler:(Exception notifyingEmergencyHandler) |
|
1080 |
Exception emergencyHandler:nil |
|
1081 |
" |
|
1082 |
||
1083 |
"Created: 15.1.1997 / 20:14:52 / cg" |
|
1084 |
"Modified: 15.1.1997 / 21:10:28 / cg" |
|
1085 |
! |
|
1086 |
||
1087 |
notifyingEmergencyHandler |
|
1088 |
"return a block (usable as an emergency handler for exceptions), |
|
1089 |
which does errorNotification before going into the debugger." |
|
1090 |
||
1091 |
^ [:ex | nil errorNotify:ex errorString from:ex suspendedContext ] |
|
1092 |
||
1093 |
"test with (try a few halts or CTRL-C's): |
|
1094 |
Exception emergencyHandler:(Exception notifyingEmergencyHandler) |
|
1095 |
" |
|
1096 |
||
1097 |
"back with: |
|
1098 |
Exception emergencyHandler:nil |
|
1099 |
" |
|
1100 |
||
1101 |
"Modified: 15.1.1997 / 20:15:12 / cg" |
|
362 | 1102 |
! ! |
1103 |
||
1 | 1104 |
!Exception methodsFor:'accessing'! |
1105 |
||
44 | 1106 |
errorString |
1107 |
"return the errorString passsed with the signal raise |
|
1108 |
(or nil, if there was none)" |
|
1109 |
||
4438 | 1110 |
^ signal errorStringExtra:errorString with:nil |
1111 |
||
1112 |
"Modified: / 12.3.1998 / 15:13:28 / stefan" |
|
1113 |
! |
|
1114 |
||
1115 |
errorString:aString |
|
1116 |
"set the errorString. |
|
1117 |
If it starts with a space, the signals errorString is prepended, |
|
1118 |
if it ends with a space, it is appended." |
|
1119 |
||
1120 |
errorString := aString |
|
1121 |
||
1122 |
"Created: / 5.3.1998 / 16:45:29 / stefan" |
|
1123 |
"Modified: / 12.3.1998 / 15:30:45 / stefan" |
|
44 | 1124 |
! |
1125 |
||
621 | 1126 |
handlerContext |
1127 |
"return the context of the handler" |
|
1128 |
||
1129 |
^ handlerContext |
|
1130 |
! |
|
1131 |
||
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1132 |
handlingSignal |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1133 |
"return the handling signal (or signalSet or Exception). |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1134 |
This is only valid during handler evaluation, and answers |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1135 |
the object which accepted the actual signal. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1136 |
(i.e. the parent or signalSet or handlerCollection)" |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1137 |
|
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1138 |
^ handlingSignal |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1139 |
! |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1140 |
|
362 | 1141 |
originator |
1142 |
"return the originator passsed with the signal raise |
|
1143 |
(or nil, if there was none)" |
|
1144 |
||
1145 |
^ originator |
|
1146 |
! |
|
1147 |
||
4438 | 1148 |
originator:anObject |
1149 |
"set the originator" |
|
1150 |
||
1151 |
originator := anObject |
|
1152 |
||
1153 |
"Created: / 5.3.1998 / 16:34:56 / stefan" |
|
1154 |
! |
|
1155 |
||
621 | 1156 |
parameter |
1157 |
"return the parameter passsed with the signal raise |
|
1158 |
(or nil, if there was none)" |
|
44 | 1159 |
|
621 | 1160 |
^ parameter |
68 | 1161 |
! |
1162 |
||
4438 | 1163 |
parameter:anObject |
1164 |
"set the parameter of the exception" |
|
1165 |
||
1166 |
parameter := anObject |
|
1167 |
||
1168 |
"Created: / 5.3.1998 / 16:34:22 / stefan" |
|
1169 |
! |
|
1170 |
||
68 | 1171 |
rejected |
362 | 1172 |
"return true, if any other of the exceptions handlers has rejected |
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
662
diff
changeset
|
1173 |
Uncertain, if this is really interesting to anybody. |
362 | 1174 |
This is only valid during handler execution. |
1175 |
(i.e. an outer handler can find out, if any other handler has already |
|
1176 |
rejected). |
|
1177 |
" |
|
68 | 1178 |
|
1179 |
^ rejected |
|
362 | 1180 |
! |
1181 |
||
621 | 1182 |
signal |
1183 |
"return the signal, that caused the exception" |
|
1184 |
||
1185 |
^ signal |
|
1186 |
! |
|
1187 |
||
4438 | 1188 |
signal:aSignal |
1189 |
"set the signal, that caused the exception" |
|
1190 |
||
1191 |
signal := aSignal |
|
1192 |
||
1193 |
"Created: / 5.3.1998 / 16:02:46 / stefan" |
|
1194 |
! |
|
1195 |
||
621 | 1196 |
suspendedContext |
1197 |
"return the context in which the raise occured" |
|
1198 |
||
1199 |
^ suspendedContext |
|
1200 |
! |
|
1201 |
||
4438 | 1202 |
suspendedContext:something |
1203 |
"set the value of the instance variable 'suspendedContext' (automatically generated)" |
|
1204 |
||
1205 |
suspendedContext := something. |
|
1206 |
||
1207 |
"Created: / 2.3.1998 / 12:43:20 / stefan" |
|
1208 |
! |
|
1209 |
||
362 | 1210 |
willProceed |
1211 |
"return true, if the exception is proceedable" |
|
1212 |
||
4438 | 1213 |
^ resumeBlock notNil and:[proceedable] |
1214 |
||
1215 |
"Modified: / 2.3.1998 / 12:20:43 / stefan" |
|
1216 |
! ! |
|
1217 |
||
1218 |
!Exception methodsFor:'copying'! |
|
1219 |
||
1220 |
postCopy |
|
1221 |
"set the internal state to nil" |
|
1222 |
||
1223 |
suspendedContext := handlerContext := rejected := nil |
|
1224 |
||
1225 |
"Created: / 2.3.1998 / 12:30:06 / stefan" |
|
1 | 1226 |
! ! |
1227 |
||
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1228 |
!Exception methodsFor:'default actions'! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1229 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1230 |
action |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1231 |
"perform a action for the signal if it hasn't been catched |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1232 |
We arrive here, if either no handler was found, or none of the |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1233 |
handlers did a return (i.e. every handler rejected or fell through). |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1234 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1235 |
The default is to evaluate the signal's handlerBlock or the |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1236 |
per process handler (if its the noHandlerSignal). |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1237 |
Finally fall back to Exceptions emergencyHandler, which is always |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1238 |
available and enters the debugger. |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1239 |
Subclasses may redefine this." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1240 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1241 |
|block noHandlerSignal msg| |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1242 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1243 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1244 |
try per signal handler |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1245 |
" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1246 |
(block := signal handlerBlock) isNil ifTrue:[ |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1247 |
"/ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1248 |
"/ if its a querySignal, ignore it |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1249 |
"/ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1250 |
signal isQuerySignal ifTrue:[^ nil]. |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1251 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1252 |
"/ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1253 |
"/ if it is not the NoHandlerSignal, raise it ... |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1254 |
"/ passing the receiver as parameter. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1255 |
"/ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1256 |
signal ~~ (noHandlerSignal := Signal noHandlerSignal) ifTrue:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1257 |
noHandlerSignal notNil ifTrue:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1258 |
handlerContext notNil ifTrue:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1259 |
msg := 'unhandled (rejected)' |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1260 |
] ifFalse:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1261 |
msg := 'unhandled' |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1262 |
]. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1263 |
msg := msg , ' exception: (' , self errorString , ')'. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1264 |
^ noHandlerSignal |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1265 |
raiseRequestWith:self |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1266 |
errorString:msg |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1267 |
in:self suspendedContext |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1268 |
]. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1269 |
"/ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1270 |
"/ mhmh - an error during early startup; noHandlerSignal is |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1271 |
"/ not yet defined. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1272 |
"/ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1273 |
^ MiniDebugger enterWithMessage:self errorString |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1274 |
]. |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1275 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1276 |
" |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1277 |
mhmh - smells like trouble - there is no handler and |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1278 |
no per-signal handler block. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1279 |
Look for either a per-process emergencyHandlerBlock |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1280 |
or the global emergencyHandler (from Exception) ... |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1281 |
" |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1282 |
Processor notNil ifTrue:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1283 |
"care for signal during startup (Processor not yet created)" |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1284 |
block := Processor activeProcess emergencySignalHandler. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1285 |
]. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1286 |
block isNil ifTrue:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1287 |
block := Exception emergencyHandler. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1288 |
block isNil ifTrue:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1289 |
"care for error during startup (Exception not yet initialized)" |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1290 |
^ MiniDebugger enterWithMessage:self errorString |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1291 |
]. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1292 |
]. |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1293 |
]. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1294 |
"... and call it" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1295 |
^ block value:self. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1296 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1297 |
"Created: / 23.7.1999 / 14:38:03 / stefan" |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1298 |
"Modified: / 25.7.1999 / 20:11:12 / stefan" |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1299 |
! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1300 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1301 |
mayProceed |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1302 |
"return true, if the exception handler is allowed to proceed |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1303 |
the execution where the exception occured. |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1304 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1305 |
Subclasses may redefine this." |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1306 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1307 |
^ signal mayProceed |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1308 |
|
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1309 |
"Created: / 23.7.1999 / 14:48:26 / stefan" |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1310 |
! ! |
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1311 |
|
621 | 1312 |
!Exception methodsFor:'handler actions'! |
1313 |
||
1314 |
proceed |
|
1315 |
"Continue after the raise - the raise returns nil" |
|
1316 |
||
2509
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1317 |
|b| |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1318 |
|
4438 | 1319 |
resumeBlock isNil ifTrue:[ |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1320 |
"signal raiser does not want us to proceed" |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1321 |
Signal proceedErrorSignal raiseWith:self. |
4438 | 1322 |
] ifFalse:[ |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1323 |
proceedable ifFalse:[ |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1324 |
('WARNING: signal <', signal printString, '> has been raised nonproceedable') errorPrintCR. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1325 |
(' by: ', suspendedContext printString) errorPrintCR. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1326 |
(' ', thisContext sender printString , ' tries to proceed.') errorPrintCR. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1327 |
(' This will be an error in future ST/X versions.') errorPrintCR. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1328 |
]. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1329 |
b := resumeBlock. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1330 |
resumeBlock := rejectBlock := handlerContext := suspendedContext := nil. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1331 |
b value:nil |
2509
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1332 |
] |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1333 |
|
4438 | 1334 |
" |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1335 |
Object errorSignal handle:[:ex| |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1336 |
ex proceed |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1337 |
] do:[ |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1338 |
Object errorSignal raise |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1339 |
]. |
4438 | 1340 |
" |
1341 |
||
1342 |
"Modified: / 27.3.1997 / 16:44:39 / cg" |
|
1343 |
"Modified: / 2.3.1998 / 12:00:10 / stefan" |
|
621 | 1344 |
! |
1345 |
||
1346 |
proceedWith:value |
|
1347 |
"Continue after the raise - the raise returns value" |
|
1348 |
||
2509
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1349 |
|b| |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1350 |
|
4438 | 1351 |
resumeBlock isNil ifTrue:[ |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1352 |
"signal raiser does not want us to proceed" |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1353 |
Signal proceedErrorSignal raiseWith:self. |
4438 | 1354 |
] ifFalse:[ |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1355 |
proceedable ifFalse:[ |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1356 |
('WARNING: signal <', signal printString, '> has been raised nonproceedable') errorPrintCR. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1357 |
(' by: ', suspendedContext printString) errorPrintCR. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1358 |
(' ', thisContext sender printString , ' tries to proceed.') errorPrintCR. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1359 |
(' This will be an error in future ST/X versions.') errorPrintCR. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1360 |
]. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1361 |
b := resumeBlock. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1362 |
resumeBlock := rejectBlock := handlerContext := suspendedContext := nil. |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1363 |
b value:value |
2509
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1364 |
] |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1365 |
|
4438 | 1366 |
"Modified: / 27.3.1997 / 16:45:57 / cg" |
1367 |
"Modified: / 2.3.1998 / 12:02:06 / stefan" |
|
621 | 1368 |
! |
1 | 1369 |
|
621 | 1370 |
reject |
1371 |
"handler decided not to handle this signal - |
|
1372 |
system will look for another handler" |
|
1373 |
||
1374 |
rejected := true. |
|
1375 |
rejectBlock value |
|
1376 |
! |
|
1377 |
||
1378 |
restart |
|
1379 |
"restart the handle:do: - usually after some repair work is done |
|
4476 | 1380 |
in the handler" |
621 | 1381 |
|
1382 |
handlerContext unwindAndRestart |
|
4476 | 1383 |
|
1384 |
" |
|
1385 |
|rslt n| |
|
1386 |
||
1387 |
Object errorSignal handle:[:ex | |
|
1388 |
'fixing divisor ...' printCR. |
|
1389 |
n := 1. |
|
1390 |
ex restart. |
|
1391 |
] do:[ |
|
1392 |
rslt := 5 / n. |
|
1393 |
]. |
|
1394 |
rslt |
|
1395 |
" |
|
621 | 1396 |
! |
1 | 1397 |
|
3100 | 1398 |
restartDo:aBlock |
1399 |
"restart the handle:do: but execute the argument, aBlock instead of the |
|
1400 |
original do-block - usually after some repair work is done in handler" |
|
1401 |
||
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1402 |
handlerContext selector == #'handle:do:' ifFalse:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1403 |
self error:'unimplemented feature'. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1404 |
]. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1405 |
|
4476 | 1406 |
"/ handlerContext unwindThenDo:[ |
1407 |
"/ handlerContext receiver |
|
1408 |
"/ handle:(handlerContext argAt:1) |
|
1409 |
"/ do:aBlock |
|
1410 |
"/ ]. |
|
1411 |
handlerContext argAt:2 put:aBlock. |
|
1412 |
handlerContext unwindAndRestart |
|
3100 | 1413 |
|
1414 |
" |
|
1415 |
|sig rslt| |
|
1416 |
||
1417 |
sig := Signal new. |
|
1418 |
||
1419 |
sig handle:[:ex | |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1420 |
ex restartDo:[ rslt := 999 ] |
3100 | 1421 |
] do:[ |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1422 |
rslt := 0. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1423 |
sig raise |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1424 |
]. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1425 |
Transcript showCR:rslt |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1426 |
" |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1427 |
|
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1428 |
" |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1429 |
|sig rslt| |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1430 |
|
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1431 |
Object errorSignal handle:[:ex | |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1432 |
ex restartDo:[ rslt := 999 ] |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1433 |
] do:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1434 |
rslt := nil foo. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1435 |
|
3100 | 1436 |
]. |
4476 | 1437 |
Transcript showCR:rslt |
1438 |
" |
|
3100 | 1439 |
|
4476 | 1440 |
" |
1441 |
|sig rslt| |
|
1442 |
||
1443 |
Object errorSignal handle:[:ex | |
|
1444 |
ex restartDo:[ 'handler' printCR. rslt := nil foo ] |
|
1445 |
] do:[ |
|
1446 |
rslt := nil foo. |
|
1447 |
||
1448 |
]. |
|
3100 | 1449 |
Transcript showCR:rslt |
1450 |
" |
|
1451 |
||
1452 |
"Modified: / 8.11.1997 / 18:52:28 / cg" |
|
1453 |
! |
|
1454 |
||
621 | 1455 |
resume |
4438 | 1456 |
"Continue after the raise - the raise returns nil |
1457 |
obsolete (use #proceed), retained for backwards compatibility" |
|
2509
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1458 |
|
4438 | 1459 |
self obsoleteMethodWarning:'use #proceed'. |
1460 |
^ self proceed |
|
2509
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1461 |
|
4438 | 1462 |
"Modified: / 2.3.1998 / 10:51:55 / stefan" |
621 | 1463 |
! |
1464 |
||
1465 |
resumeWith:value |
|
4438 | 1466 |
"Continue after the raise - the raise returns value |
1467 |
obsolete (use #proceedWith:), retained for backwards compatibility" |
|
2509
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1468 |
|
4438 | 1469 |
self obsoleteMethodWarning:'use #proceedWith:'. |
1470 |
^ self proceedWith:value |
|
2509
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1471 |
|
4438 | 1472 |
"Modified: / 2.3.1998 / 10:51:48 / stefan" |
621 | 1473 |
! |
1474 |
||
1475 |
return |
|
1476 |
"Continue after the handle:do: - the handle:do: returns nil" |
|
1477 |
||
2509
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1478 |
|con| |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1479 |
|
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1480 |
con := handlerContext. |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1481 |
resumeBlock := rejectBlock := handlerContext := suspendedContext := nil. |
4478
782108345281
avoid a delegating send in handler-return action.
Claus Gittinger <cg@exept.de>
parents:
4476
diff
changeset
|
1482 |
con unwind:nil |
2509
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1483 |
|
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1484 |
"Modified: 27.3.1997 / 16:46:39 / cg" |
621 | 1485 |
! |
1486 |
||
1487 |
returnDoing:aBlock |
|
1488 |
"Continue after the handle:do: - the handle:do: returns aBlock value" |
|
1489 |
||
1490 |
handlerContext unwindThenDo:aBlock |
|
1491 |
! |
|
1492 |
||
1493 |
returnWith:value |
|
1494 |
"Continue after the handle:do: - the handle:do: returns value" |
|
1495 |
||
2509
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1496 |
|con| |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1497 |
|
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1498 |
con := handlerContext. |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1499 |
resumeBlock := rejectBlock := handlerContext := suspendedContext := nil. |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1500 |
con unwind:value |
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1501 |
|
20e70b07473a
clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1502 |
"Modified: 27.3.1997 / 16:46:51 / cg" |
171 | 1503 |
! ! |
1504 |
||
4438 | 1505 |
!Exception methodsFor:'private'! |
1 | 1506 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1507 |
XXdoRaise |
171 | 1508 |
"search through the context-calling chain for a 'handle:do:'-context |
1609
21f69f2adef7
when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1509 |
to the raising signal, a parent of it, or a SignalSet which includes |
171 | 1510 |
the raising signal. |
1511 |
If found, take the contexts 2nd argument (the handler) and evaluate |
|
1512 |
it with the receiver exception as argument. |
|
217 | 1513 |
If no handler is found, try per signal handler, or |
1514 |
per process handler (if its the noHandlerSignal). |
|
1515 |
Finally fall back to Exceptions emergencyHandler, which is always |
|
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1516 |
available and enters the debugger. |
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1517 |
ATTENTION: the code below depends on being called by #raise or |
1609
21f69f2adef7
when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1518 |
#raiseRequest for proper operation (it skips the sending context)." |
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1519 |
|
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1520 |
|theContext conArg1 |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1521 |
theSignal c ex1 activeHandlers inHandler |
3509 | 1522 |
lastHandler h r firstHandler| |
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1523 |
|
4438 | 1524 |
"/ is nil a valid originator? If so, we need an extra |
1525 |
"/ instanceVariable to record the originator setting. |
|
1526 |
||
1527 |
originator isNil ifTrue:[ |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1528 |
originator := suspendedContext homeReceiver |
4438 | 1529 |
]. |
1530 |
||
3100 | 1531 |
theSignal := signal. |
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1532 |
theSignal isSignal ifFalse:[ |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1533 |
self halt:'unexpected non-Signal in calling context'. |
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1534 |
]. |
171 | 1535 |
|
1609
21f69f2adef7
when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1536 |
"/ 'search handler for: ' print. theSignal displayString printCR. |
21f69f2adef7
when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1537 |
|
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1538 |
inHandler := false. |
3100 | 1539 |
c := thisContext sender sender. "the raise/raiseRequest-context" |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1540 |
"the signal raise context" |
1609
21f69f2adef7
when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1541 |
|
2204 | 1542 |
"/ since the exceptionHandler is evaluated onTop of the |
1543 |
"/ contextChain, we must skip active handlers before searching. |
|
1544 |
"/ otherwise, we get into trouble, when re-raising an exception |
|
1545 |
"/ from within a handler (which would lead to re-executing the |
|
1546 |
"/ same handler) |
|
1547 |
"/ the code below collects active handlers ... |
|
1548 |
||
3066 | 1549 |
"/ on the fly, look for the first #handle:do: - context, |
1550 |
"/ and remember it (as firstHandler) to avoid walking the context chain twice |
|
1551 |
"/ in most cases ... |
|
2291
af7652b82404
avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents:
2282
diff
changeset
|
1552 |
|
3066 | 1553 |
firstHandler := nil. |
2208 | 1554 |
|
3066 | 1555 |
[c notNil] whileTrue:[ |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1556 |
firstHandler isNil ifTrue:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1557 |
c := c findNextContextWithSelector:#doRaise or:#'handle:do:' or:#'handle:from:do:'. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1558 |
] ifFalse:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1559 |
c := c findNextContextWithSelector:#doRaise or:nil or:nil. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1560 |
]. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1561 |
c notNil ifTrue:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1562 |
(c selector == #doRaise) ifTrue:[ |
1609
21f69f2adef7
when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1563 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1564 |
ex1 := c receiver. |
3066 | 1565 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1566 |
((ex1 class == self class) |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1567 |
or:[ex1 species == self species]) ifTrue:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1568 |
(ex1 signal == theSignal) ifTrue:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1569 |
h := ex1 handlerContext. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1570 |
h notNil ifTrue:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1571 |
r := h receiver. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1572 |
(r notNil and:[r accepts:theSignal]) ifTrue:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1573 |
activeHandlers isNil ifTrue:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1574 |
activeHandlers := OrderedCollection new |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1575 |
]. |
2208 | 1576 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1577 |
lastHandler := h. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1578 |
activeHandlers add:lastHandler. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1579 |
inHandler := true. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1580 |
c := lastHandler. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1581 |
] |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1582 |
] |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1583 |
] |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1584 |
] |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1585 |
] ifFalse:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1586 |
"/ must be a #handle:do context ... |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1587 |
firstHandler := c. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1588 |
] |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1589 |
] |
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1590 |
]. |
171 | 1591 |
|
2208 | 1592 |
"/ now, start searching for a handler, |
3066 | 1593 |
"/ start search above the last active handler. |
1594 |
"/ Or start with the first handle:do: context, if one |
|
1595 |
"/ was found as a side effect of the previous handler search. |
|
1596 |
"/ If nil, then there is no handler and we can directly proceed |
|
1597 |
"/ to the unhandled code below. |
|
2208 | 1598 |
|
3179
f22e94c6ae83
oops - handler within a handler block did not catch
Claus Gittinger <cg@exept.de>
parents:
3111
diff
changeset
|
1599 |
"/ lastHandler notNil ifTrue:[ |
f22e94c6ae83
oops - handler within a handler block did not catch
Claus Gittinger <cg@exept.de>
parents:
3111
diff
changeset
|
1600 |
"/ theContext := lastHandler. |
f22e94c6ae83
oops - handler within a handler block did not catch
Claus Gittinger <cg@exept.de>
parents:
3111
diff
changeset
|
1601 |
"/ theContext := lastHandler findNextContextWithSelector:#'handle:do:' or:#'handle:from:do:' or:nil. |
f22e94c6ae83
oops - handler within a handler block did not catch
Claus Gittinger <cg@exept.de>
parents:
3111
diff
changeset
|
1602 |
"/ ] ifFalse:[ |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1603 |
theContext := firstHandler. |
3179
f22e94c6ae83
oops - handler within a handler block did not catch
Claus Gittinger <cg@exept.de>
parents:
3111
diff
changeset
|
1604 |
"/ ]. |
1609
21f69f2adef7
when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1605 |
|
2291
af7652b82404
avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents:
2282
diff
changeset
|
1606 |
[theContext notNil] whileTrue:[ |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1607 |
(theContext selector == #'handle:do:' |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1608 |
or:[(theContext argAt:2) == originator]) |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1609 |
ifTrue:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1610 |
(activeHandlers notNil |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1611 |
and:[activeHandlers includesIdentical:theContext]) ifTrue:[ |
3068 | 1612 |
"/ 'skip activeHandler: ' print. theContext displayString printCR. |
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1613 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1614 |
] ifFalse:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1615 |
" |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1616 |
if this is the Signal>>handle:do: context |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1617 |
or a SignalSet>>handle:do: context with self in it, |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1618 |
call the handler |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1619 |
" |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1620 |
r := theContext receiver. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1621 |
(r notNil and:[r accepts:signal]) ifTrue:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1622 |
"call the handler" |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1623 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1624 |
conArg1 := theContext argAt:1. |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1625 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1626 |
handlerContext := theContext. |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1627 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1628 |
self doCallHandler:conArg1. |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1629 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1630 |
"/ if the handler rejects, we arrive here |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1631 |
"/ continue search for another handler |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1632 |
]. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1633 |
] |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1634 |
]. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1635 |
theContext := theContext findNextContextWithSelector:#'handle:do:' or:#'handle:from:do:' or:nil. |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1636 |
]. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1637 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1638 |
activeHandlers := nil. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1639 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1640 |
" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1641 |
we arrive here, if either no handler was found, or none of the |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1642 |
handlers did a return (i.e. every handler rejected or fell through). |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1643 |
" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1644 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1645 |
^ self action |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1646 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1647 |
"Modified: / 9.11.1997 / 14:48:44 / cg" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1648 |
"Modified: / 23.7.1999 / 14:40:12 / stefan" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1649 |
"Created: / 25.7.1999 / 20:13:19 / stefan" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1650 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1651 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1652 |
doCallHandler:aHandler |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1653 |
"call the handler proper - needed an extra method |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1654 |
to have a separate returnContext for the rejectBlock. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1655 |
(which is historical, and actually no longer needed)" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1656 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1657 |
|val| |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1658 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1659 |
rejectBlock := [^ self]. "this will return on reject" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1660 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1661 |
thisContext markForRaise. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1662 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1663 |
val := aHandler value:self. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1664 |
" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1665 |
handler fall through - is just like a returnWith:blocks-value |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1666 |
" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1667 |
rejectBlock := nil. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1668 |
self returnWith:val |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1669 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1670 |
"Modified: / 26.7.1999 / 14:41:55 / stefan" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1671 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1672 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1673 |
doRaise |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1674 |
"search through the context-calling chain for a handle-context |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1675 |
to the raising signal, a parent of it, or a SignalSet which includes |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1676 |
the raising signal. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1677 |
If found, ask the receiver for the handler and evaluate |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1678 |
it with the receiver exception as argument. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1679 |
If no handler is found, perform the default #action method. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1680 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1681 |
ATTENTION: the code below depends on being called by #raise or |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1682 |
#raiseRequest for proper operation (it skips the sending context)." |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1683 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1684 |
|theContext handler |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1685 |
theSignal c ex1 activeHandlers inHandler |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1686 |
lastHandler h r firstHandler searchForHandle searchForRaise| |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1687 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1688 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1689 |
"/ is nil a valid originator? If so, we need an extra |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1690 |
"/ instanceVariable to record the originator setting. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1691 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1692 |
originator isNil ifTrue:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1693 |
originator := suspendedContext homeReceiver |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1694 |
]. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1695 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1696 |
theSignal := signal. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1697 |
theSignal isSignal ifFalse:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1698 |
self halt:'unexpected non-Signal in calling context'. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1699 |
]. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1700 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1701 |
"/ 'search handler for: ' print. theSignal displayString printCR. |
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1702 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1703 |
"/ inHandler := false. |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1704 |
c := thisContext sender sender. "the raise/raiseRequest-context" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1705 |
"the signal raise context" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1706 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1707 |
"/ since the exceptionHandler is evaluated on top of the |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1708 |
"/ contextChain, we must skip active handlers before searching. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1709 |
"/ otherwise, we get into trouble, when re-raising an exception |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1710 |
"/ from within a handler (which would lead to re-executing the |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1711 |
"/ same handler) |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1712 |
"/ the code below collects active handlers ... |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1713 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1714 |
"/ on the fly, look for the first handle - context, |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1715 |
"/ and remember it (as firstHandler) to avoid walking the context chain twice |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1716 |
"/ in most cases ... |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1717 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1718 |
firstHandler := nil. |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1719 |
searchForHandle := searchForRaise := true. |
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1720 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1721 |
[c notNil] whileTrue:[ |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1722 |
c := c findSpecialHandle:searchForHandle raise:searchForRaise. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1723 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1724 |
c notNil ifTrue:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1725 |
(c isRaiseContext) ifTrue:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1726 |
ex1 := c receiver. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1727 |
((ex1 class == self class) |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1728 |
or:[ex1 species == self species]) ifTrue:[ |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1729 |
h := ex1 handlerContext. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1730 |
h notNil ifTrue:[ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1731 |
((ex1 signal == theSignal) |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1732 |
|
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1733 |
"/ mhmh - if not ==, the raised signal there is not ours, |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1734 |
"/ but the handler could still be for a signalSet, parentSig |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1735 |
"/ or other thingy which accepts our signal. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1736 |
"/ If we ommit that check, a signalSet-handler gets invoked |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1737 |
"/ again by an exception occuring inside its handler. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1738 |
|
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1739 |
"/ to avoid overhead, only do it if the |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1740 |
"/ handlers receiver is not of the signals class... |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1741 |
"/ ...i.e. knowing that most are r handle:do: contexts, |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1742 |
"/ where the receiver is the handling signal. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1743 |
or:[h receiver ~~ ex1 signal |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1744 |
and:[ex1 handlingSignal accepts:theSignal]]) ifTrue:[ |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1745 |
activeHandlers isNil ifTrue:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1746 |
activeHandlers := OrderedCollection new |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1747 |
]. |
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1748 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1749 |
activeHandlers add:h. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1750 |
"/ lastHandler := h. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1751 |
"/ inHandler := true. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1752 |
c := h. |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1753 |
] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1754 |
] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1755 |
] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1756 |
] ifFalse:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1757 |
"/ must be a handle context ... |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1758 |
firstHandler := c. |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1759 |
searchForHandle := false. |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1760 |
] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1761 |
] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1762 |
]. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1763 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1764 |
"/ now, start searching for a handler, |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1765 |
"/ start search above the last active handler. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1766 |
"/ Or start with the first handle context, if one |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1767 |
"/ was found as a side effect of the previous handler search. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1768 |
"/ If nil, then there is no handler and we can directly proceed |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1769 |
"/ to the unhandled code below. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1770 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1771 |
"/ lastHandler notNil ifTrue:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1772 |
"/ theContext := lastHandler. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1773 |
"/ theContext := lastHandler findNextHandleContext |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1774 |
"/ ] ifFalse:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1775 |
theContext := firstHandler. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1776 |
"/ ]. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1777 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1778 |
[theContext notNil] whileTrue:[ |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1779 |
"/ |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1780 |
"/ ask the Signal instance/Exception class for the handler. |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1781 |
"/ nil is returned, if the signal is not accepted |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1782 |
"/ |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1783 |
r := theContext receiver. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1784 |
(r notNil and:[(handler := r handlerForSignal:signal |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1785 |
context:theContext |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1786 |
originator:originator) notNil] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1787 |
) ifTrue:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1788 |
(activeHandlers notNil |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1789 |
and:[activeHandlers includesIdentical:theContext]) ifTrue:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1790 |
"/ 'skip activeHandler: ' print. theContext displayString printCR. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1791 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1792 |
] ifFalse:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1793 |
"call the handler" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1794 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1795 |
handlerContext := theContext. |
4476 | 1796 |
"/ remember the handling signal, sigSet, or exception |
1797 |
"/ for the #accepts: check above |
|
1798 |
handlingSignal := r handlingExceptionInContext:theContext. |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1799 |
self doCallHandler:handler. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1800 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1801 |
"/ if the handler rejects, we arrive here |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1802 |
"/ continue search for another handler |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1803 |
]. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1804 |
]. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1805 |
theContext := theContext findSpecialHandle:true raise:false. |
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1806 |
]. |
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1807 |
|
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1808 |
"/ help GC a bit, by clearing things we no longer need |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1809 |
"/ (especially useful for contexts ...) |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1810 |
activeHandlers := handler := c := ex1 := firstHandler := nil. |
1482
f4b65def90e1
oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents:
1378
diff
changeset
|
1811 |
|
171 | 1812 |
" |
4472
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1813 |
we arrive here, if either no handler was found, |
c5262e0e3130
added #handlingSignalInContext: and changed doRaise
Claus Gittinger <cg@exept.de>
parents:
4466
diff
changeset
|
1814 |
or every handler rejected. |
171 | 1815 |
" |
1118
1037616d9add
ignore unhandled querySignals
Claus Gittinger <cg@exept.de>
parents:
1038
diff
changeset
|
1816 |
|
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1817 |
^ self action |
1118
1037616d9add
ignore unhandled querySignals
Claus Gittinger <cg@exept.de>
parents:
1038
diff
changeset
|
1818 |
|
3066 | 1819 |
"Created: / 12.5.1996 / 15:09:39 / cg" |
3100 | 1820 |
"Modified: / 9.11.1997 / 14:48:44 / cg" |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4449
diff
changeset
|
1821 |
"Modified: / 26.7.1999 / 14:50:50 / stefan" |
4438 | 1822 |
! ! |
1823 |
||
1824 |
!Exception methodsFor:'raising'! |
|
1378
056b3a0928f2
oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
1825 |
|
056b3a0928f2
oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
1826 |
raise |
4438 | 1827 |
"actually raise a non-proceedable exception |
1828 |
||
1829 |
In the past, ST/X did not distinguish between proceedable and |
|
1830 |
non-proceedable signals (signals invoked with #raise could proceed). |
|
1831 |
To allow a migration of old applications, we do not invoke a signal |
|
1832 |
but print out a warning, when trying to proceed a non-proceedable signal. |
|
1833 |
In the next release, this will raise a signal, so fix your code" |
|
1378
056b3a0928f2
oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
1834 |
|
4438 | 1835 |
suspendedContext isNil ifTrue:[ |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1836 |
"Call chain: |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1837 |
(origin)>>someMethod sender |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1838 |
Signal>>raise sender |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1839 |
Exception>>raise thisContext |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1840 |
" |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1841 |
suspendedContext := thisContext sender sender |
4438 | 1842 |
]. |
1843 |
||
1844 |
"/ remove the next 2 lines to make proceeding from non-proceedable signals an error. |
|
1845 |
proceedable := false. |
|
1378
056b3a0928f2
oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
1846 |
resumeBlock := [:value | ^ value]. |
4438 | 1847 |
|
1378
056b3a0928f2
oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
1848 |
^ self doRaise |
056b3a0928f2
oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
1849 |
|
4438 | 1850 |
"Modified: / 12.5.1996 / 15:09:47 / cg" |
1851 |
"Modified: / 5.3.1998 / 16:40:23 / stefan" |
|
1 | 1852 |
! |
1853 |
||
621 | 1854 |
raiseRequest |
1855 |
"actually raise a proceedable exception." |
|
1 | 1856 |
|
4438 | 1857 |
suspendedContext isNil ifTrue:[ |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1858 |
"Call chain: |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1859 |
(origin)>>someMethod sender |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1860 |
Signal>>raise sender |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1861 |
Exception>>raise thisContext |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1862 |
" |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1863 |
suspendedContext := thisContext sender sender |
4438 | 1864 |
]. |
1865 |
||
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1866 |
self mayProceed ifFalse:[ |
4449
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1867 |
"/ proceeding from wrongProceedabilitySignal grants the raiseRequest |
c8e195e21aab
stc doesn't grok lowercase class instvars
Stefan Vogel <sv@exept.de>
parents:
4447
diff
changeset
|
1868 |
Signal wrongProceedabilitySignal raiseRequestWith:signal in:suspendedContext |
4438 | 1869 |
]. |
1870 |
proceedable := true. |
|
1378
056b3a0928f2
oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
1871 |
resumeBlock := [:value | ^ value]. |
056b3a0928f2
oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
1872 |
^ self doRaise |
1376
6757590defbf
avoid extra send (raise->evaluateHandler)
Claus Gittinger <cg@exept.de>
parents:
1363
diff
changeset
|
1873 |
|
4438 | 1874 |
"Modified: / 12.5.1996 / 15:09:44 / cg" |
4445
7011a3da6c72
First shot on class based exceptions.
Stefan Vogel <sv@exept.de>
parents:
4441
diff
changeset
|
1875 |
"Modified: / 23.7.1999 / 14:48:48 / stefan" |
621 | 1876 |
! ! |
1 | 1877 |
|
621 | 1878 |
!Exception methodsFor:'setup'! |
1 | 1879 |
|
4441 | 1880 |
signal:aSignal originator:origin |
1881 |
"set the fields usable for inspection by the handler |
|
1882 |
- only to be sent from the signal when raising" |
|
1883 |
||
1884 |
signal := aSignal. |
|
1885 |
originator := origin. |
|
1886 |
||
1887 |
"Created: / 23.7.1999 / 13:39:35 / stefan" |
|
1888 |
! |
|
1889 |
||
621 | 1890 |
signal:aSignal parameter:aParameter errorString:aString suspendedContext:sContext originator:origin |
1891 |
"set the fields usable for inspection by the handler |
|
1892 |
- only to be sent from the signal when raising" |
|
328 | 1893 |
|
621 | 1894 |
signal := aSignal. |
1895 |
parameter := aParameter. |
|
1896 |
errorString := aString. |
|
1897 |
suspendedContext := sContext. |
|
1898 |
originator := origin. |
|
1899 |
! ! |
|
328 | 1900 |
|
1953
c8a3af54acb3
unhandled querySignals should return nil
Claus Gittinger <cg@exept.de>
parents:
1710
diff
changeset
|
1901 |
!Exception class methodsFor:'documentation'! |
662 | 1902 |
|
1903 |
version |
|
4478
782108345281
avoid a delegating send in handler-return action.
Claus Gittinger <cg@exept.de>
parents:
4476
diff
changeset
|
1904 |
^ '$Header: /cvs/stx/stx/libbasic/Exception.st,v 1.75 1999-07-31 14:34:56 cg Exp $' |
662 | 1905 |
! ! |
621 | 1906 |
Exception initialize! |