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