author | Claus Gittinger <cg@exept.de> |
Thu, 27 Jun 2019 15:21:18 +0200 | |
changeset 24377 | 2fbcb2fa6c43 |
parent 24111 | 2c17f738ce20 |
child 24592 | b003befd8100 |
permissions | -rw-r--r-- |
7586 | 1 |
" |
2 |
COPYRIGHT (c) 2001 by eXept Software AG |
|
3 |
All Rights Reserved |
|
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 |
" |
|
5976 | 12 |
"{ Package: 'stx:libbasic' }" |
13 |
||
18290
5ea0b888d79d
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
16414
diff
changeset
|
14 |
"{ NameSpace: Smalltalk }" |
5ea0b888d79d
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
16414
diff
changeset
|
15 |
|
20447 | 16 |
ExecutionError subclass:#MessageNotUnderstood |
5976 | 17 |
instanceVariableNames:'' |
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
6210
d7039e2ae776
caetgory change and documentation added
Claus Gittinger <cg@exept.de>
parents:
5982
diff
changeset
|
20 |
category:'Kernel-Exceptions-Errors' |
5976 | 21 |
! |
22 |
||
6210
d7039e2ae776
caetgory change and documentation added
Claus Gittinger <cg@exept.de>
parents:
5982
diff
changeset
|
23 |
!MessageNotUnderstood class methodsFor:'documentation'! |
d7039e2ae776
caetgory change and documentation added
Claus Gittinger <cg@exept.de>
parents:
5982
diff
changeset
|
24 |
|
7586 | 25 |
copyright |
26 |
" |
|
27 |
COPYRIGHT (c) 2001 by eXept Software AG |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
6210
d7039e2ae776
caetgory change and documentation added
Claus Gittinger <cg@exept.de>
parents:
5982
diff
changeset
|
39 |
documentation |
d7039e2ae776
caetgory change and documentation added
Claus Gittinger <cg@exept.de>
parents:
5982
diff
changeset
|
40 |
" |
d7039e2ae776
caetgory change and documentation added
Claus Gittinger <cg@exept.de>
parents:
5982
diff
changeset
|
41 |
raised when a message is sent to an object, which is not understood |
d7039e2ae776
caetgory change and documentation added
Claus Gittinger <cg@exept.de>
parents:
5982
diff
changeset
|
42 |
by the receiver, and the message was not handled by a class specific |
d7039e2ae776
caetgory change and documentation added
Claus Gittinger <cg@exept.de>
parents:
5982
diff
changeset
|
43 |
doesNotUnderstand: handler. |
d7039e2ae776
caetgory change and documentation added
Claus Gittinger <cg@exept.de>
parents:
5982
diff
changeset
|
44 |
" |
d7039e2ae776
caetgory change and documentation added
Claus Gittinger <cg@exept.de>
parents:
5982
diff
changeset
|
45 |
! ! |
5976 | 46 |
|
15188
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
47 |
!MessageNotUnderstood class methodsFor:'initialization'! |
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
48 |
|
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
49 |
initialize |
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
50 |
NotifierString := 'message not understood'. |
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
51 |
|
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
52 |
" |
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
53 |
self initialize |
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
54 |
" |
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
55 |
! ! |
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
56 |
|
6667 | 57 |
!MessageNotUnderstood class methodsFor:'save evaluation'! |
58 |
||
59 |
ignoreNotUnderstoodOf:aSelector in:aBlock |
|
60 |
"evaluate aBlock; if a messageNotUnderstood occurs, |
|
61 |
for which the message was aSelector, ignore the error |
|
62 |
and return. |
|
63 |
Other selector errors lead into the debugger. |
|
23887 | 64 |
If no error occurs, return the block's value" |
6667 | 65 |
|
66 |
^ self handle:[:ex | |
|
6669 | 67 |
ex selector == aSelector ifFalse:[ |
6667 | 68 |
ex reject |
69 |
] |
|
70 |
] do:aBlock. |
|
23887 | 71 |
|
72 |
"Modified (comment): / 13-03-2019 / 10:26:10 / Claus Gittinger" |
|
6668 | 73 |
! |
74 |
||
75 |
ignoreNotUnderstoodOfAny:aCollectionOfSelectors in:aBlock |
|
76 |
"evaluate aBlock; if a messageNotUnderstood occurs, |
|
77 |
for which the message was any in aCollectionOfSelectors, ignore the error |
|
78 |
and return. |
|
79 |
Other selector errors lead into the debugger. |
|
23887 | 80 |
If no error occurs, return the block's value" |
6668 | 81 |
|
82 |
^ self handle:[:ex | |
|
6669 | 83 |
(aCollectionOfSelectors includesIdentical:ex selector) ifFalse:[ |
6668 | 84 |
ex reject |
85 |
] |
|
86 |
] do:aBlock. |
|
23887 | 87 |
|
88 |
"Modified (comment): / 13-03-2019 / 10:26:14 / Claus Gittinger" |
|
6667 | 89 |
! ! |
90 |
||
5982 | 91 |
!MessageNotUnderstood methodsFor:'accessing'! |
92 |
||
93 |
message |
|
94 |
^ parameter |
|
95 |
||
96 |
" |
|
97 |
[ |
|
98 |
123 perform:#foo |
|
99 |
] on:MessageNotUnderstood do:[:ex | |
|
100 |
Transcript show:'message object: '; showCR:ex message storeString. |
|
101 |
Transcript show:'receiver: '; showCR:ex receiver storeString. |
|
102 |
Transcript show:'selector: '; showCR:ex message selector storeString. |
|
103 |
Transcript show:'arguments: '; showCR:ex message arguments storeString. |
|
104 |
] |
|
105 |
" |
|
106 |
! |
|
107 |
||
108 |
receiver |
|
109 |
^ originator |
|
110 |
||
111 |
" |
|
112 |
[ |
|
113 |
123 perform:#foo |
|
114 |
] on:MessageNotUnderstood do:[:ex | |
|
115 |
Transcript showCR:ex receiver |
|
116 |
] |
|
117 |
" |
|
6668 | 118 |
! |
119 |
||
120 |
selector |
|
121 |
^ parameter selector |
|
122 |
||
123 |
" |
|
124 |
[ |
|
125 |
123 perform:#foo |
|
126 |
] on:MessageNotUnderstood do:[:ex | |
|
127 |
Transcript show:'selector: '; showCR:ex selector storeString. |
|
128 |
] |
|
129 |
" |
|
5982 | 130 |
! ! |
131 |
||
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
132 |
!MessageNotUnderstood methodsFor:'printing & storing'! |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
133 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
134 |
description |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
135 |
"the human readable description of the exception" |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
136 |
|
18302
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
137 |
|searchClass sel description sender| |
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
138 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
139 |
"extract the class that should have implemented the message. |
16414
718569261384
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
15188
diff
changeset
|
140 |
(in case of a super-send, this is not the receiver's class)" |
18302
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
141 |
|
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
142 |
"/ suspendedContext is the actual doesNotUnderstand context; |
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
143 |
"/ its sender is the bad (failing) one, which has the search class information |
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
144 |
"/ (the doesNotUnderstand is always an undirected send) |
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
145 |
"/ Q: is that correct VM-behavior? |
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
146 |
"/ One might argue, that the DNU should be also directed |
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
147 |
"/ (or else add the searchClass information to the Message object) |
8657 | 148 |
suspendedContext notNil ifTrue:[ |
18302
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
149 |
searchClass := suspendedContext searchClass. |
18290
5ea0b888d79d
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
16414
diff
changeset
|
150 |
(sender := suspendedContext sender) notNil ifTrue:[ |
18302
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
151 |
"/ just in case, this gets ever fixed |
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
152 |
sender receiver == suspendedContext receiver ifTrue:[ |
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
153 |
searchClass := sender searchClass. |
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
154 |
]. |
16414
718569261384
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
15188
diff
changeset
|
155 |
]. |
8657 | 156 |
]. |
18302
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
157 |
searchClass isNil ifTrue:[ |
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
158 |
searchClass := self receiver class. |
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
159 |
]. |
18302
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
160 |
searchClass notNil ifTrue:[ |
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
161 |
"displayString is better than 'cls name', |
22522 | 162 |
since it appends (obsolete) for outdated classes |
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
163 |
(this happens if you send messages to old instances |
22522 | 164 |
after changing a classes definition), |
165 |
and may be also redefined for non-Smalltalk object (i.e. BridgeObjects)" |
|
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
166 |
|
22524 | 167 |
searchClass == self receiver class ifTrue:[ |
168 |
description := self receiver classDisplayString. |
|
169 |
] ifFalse:[ |
|
170 |
description := searchClass displayString. |
|
171 |
]. |
|
10446
21f13f605ff5
changed #description - take care if the classes displayString is not a String
Stefan Vogel <sv@exept.de>
parents:
8657
diff
changeset
|
172 |
description isString ifFalse:[ |
21f13f605ff5
changed #description - take care if the classes displayString is not a String
Stefan Vogel <sv@exept.de>
parents:
8657
diff
changeset
|
173 |
description := '(** ???-class **)' |
21f13f605ff5
changed #description - take care if the classes displayString is not a String
Stefan Vogel <sv@exept.de>
parents:
8657
diff
changeset
|
174 |
]. |
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
175 |
] ifFalse:[ |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
176 |
description := '(** nil-class **)' |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
177 |
]. |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
178 |
sel := self selector. |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
179 |
sel class == Symbol ifTrue:[ |
23169 | 180 |
self receiver isNil ifTrue:[ |
23656 | 181 |
description := 'receiver of "',sel printString,'" is nil'. |
23169 | 182 |
] ifFalse:[ |
24111 | 183 |
(searchClass notNil and:[self receiver isBridgeProxy not and:[searchClass programmingLanguage isSmalltalk]]) ifTrue:[ |
184 |
description := description , ' does not understand: "',sel,'"'. |
|
185 |
"/ description := sel, ' not understood by ' , description. |
|
186 |
] ifFalse:[ |
|
187 |
description := description , ' does not implement: ' , sel. |
|
188 |
]. |
|
23169 | 189 |
]. |
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
190 |
] ifFalse:[ |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
191 |
"a non-symbol selector may happen when things go mad in a primitive, |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
192 |
or a method has been called by #perform: or #valueWithReceiver: with a wrong arg." |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
193 |
|
22522 | 194 |
"/ assume that it might be ok with other prog. languages |
24110 | 195 |
(searchClass notNil and:[self receiver isBridgeProxy not and:[searchClass programmingLanguage isSmalltalk]]) ifTrue:[ |
23286 | 196 |
description := description , ' does not understand (nonSymbol): ' , sel printString. |
22522 | 197 |
"/ description := sel printString, ' (nonSymbol) not understood by ' , description. |
22524 | 198 |
] ifFalse:[ |
199 |
description := description , ' does not implement: ' , sel printString. |
|
22522 | 200 |
]. |
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
201 |
]. |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
202 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
203 |
^ description |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
204 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
205 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
206 |
" |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
207 |
2 foo:3 |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
208 |
2 perform:55 |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
209 |
nil // 2 |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
210 |
" |
13028 | 211 |
|
212 |
"Modified: / 19-08-2010 / 15:33:03 / cg" |
|
24110 | 213 |
"Modified: / 07-05-2019 / 17:31:24 / Stefan Vogel" |
24111 | 214 |
"Modified: / 08-05-2019 / 00:52:54 / Claus Gittinger" |
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
215 |
! ! |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
216 |
|
5976 | 217 |
!MessageNotUnderstood class methodsFor:'documentation'! |
218 |
||
219 |
version |
|
20447 | 220 |
^ '$Header$' |
13028 | 221 |
! |
222 |
||
223 |
version_CVS |
|
20447 | 224 |
^ '$Header$' |
5976 | 225 |
! ! |
15188
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
226 |
|
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
227 |
|
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
228 |
MessageNotUnderstood initialize! |