author | Claus Gittinger <cg@exept.de> |
Sat, 06 Jun 2015 13:42:28 +0200 | |
changeset 18449 | 48c31fe80359 |
parent 18302 | 67840a4affd1 |
child 18304 | 424139e100b2 |
child 20447 | 4b8519e42c13 |
permissions | -rw-r--r-- |
18290
5ea0b888d79d
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
16414
diff
changeset
|
1 |
"{ Encoding: utf8 }" |
5ea0b888d79d
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
16414
diff
changeset
|
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 |
|
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
18 |
ProceedableError 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. |
|
66 |
If no error occurs, return the blocks value" |
|
67 |
||
68 |
^ self handle:[:ex | |
|
6669 | 69 |
ex selector == aSelector ifFalse:[ |
6667 | 70 |
ex reject |
71 |
] |
|
72 |
] do:aBlock. |
|
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. |
|
80 |
If no error occurs, return the blocks value" |
|
81 |
||
82 |
^ self handle:[:ex | |
|
6669 | 83 |
(aCollectionOfSelectors includesIdentical:ex selector) ifFalse:[ |
6668 | 84 |
ex reject |
85 |
] |
|
86 |
] do:aBlock. |
|
6667 | 87 |
! ! |
88 |
||
5982 | 89 |
!MessageNotUnderstood methodsFor:'accessing'! |
90 |
||
91 |
message |
|
92 |
^ parameter |
|
93 |
||
94 |
" |
|
95 |
[ |
|
96 |
123 perform:#foo |
|
97 |
] on:MessageNotUnderstood do:[:ex | |
|
98 |
Transcript show:'message object: '; showCR:ex message storeString. |
|
99 |
Transcript show:'receiver: '; showCR:ex receiver storeString. |
|
100 |
Transcript show:'selector: '; showCR:ex message selector storeString. |
|
101 |
Transcript show:'arguments: '; showCR:ex message arguments storeString. |
|
102 |
] |
|
103 |
" |
|
104 |
! |
|
105 |
||
106 |
receiver |
|
107 |
^ originator |
|
108 |
||
109 |
" |
|
110 |
[ |
|
111 |
123 perform:#foo |
|
112 |
] on:MessageNotUnderstood do:[:ex | |
|
113 |
Transcript showCR:ex receiver |
|
114 |
] |
|
115 |
" |
|
6668 | 116 |
! |
117 |
||
118 |
selector |
|
119 |
^ parameter selector |
|
120 |
||
121 |
" |
|
122 |
[ |
|
123 |
123 perform:#foo |
|
124 |
] on:MessageNotUnderstood do:[:ex | |
|
125 |
Transcript show:'selector: '; showCR:ex selector storeString. |
|
126 |
] |
|
127 |
" |
|
5982 | 128 |
! ! |
129 |
||
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
130 |
!MessageNotUnderstood methodsFor:'printing & storing'! |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
131 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
132 |
description |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
133 |
"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
|
134 |
|
18302
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
135 |
|searchClass sel description sender| |
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
136 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
137 |
"extract the class that should have implemented the message. |
16414
718569261384
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
15188
diff
changeset
|
138 |
(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
|
139 |
|
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
140 |
"/ suspendedContext is the actual doesNotUnderstand context; |
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
141 |
"/ 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
|
142 |
"/ (the doesNotUnderstand is always an undirected send) |
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
143 |
"/ Q: is that correct VM-behavior? |
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
144 |
"/ One might argue, that the DNU should be also directed |
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
145 |
"/ (or else add the searchClass information to the Message object) |
8657 | 146 |
suspendedContext notNil ifTrue:[ |
18302
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
147 |
searchClass := suspendedContext searchClass. |
18290
5ea0b888d79d
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
16414
diff
changeset
|
148 |
(sender := suspendedContext sender) notNil ifTrue:[ |
18302
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
149 |
"/ just in case, this gets ever fixed |
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
150 |
sender receiver == suspendedContext receiver ifTrue:[ |
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
151 |
searchClass := sender searchClass. |
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
152 |
]. |
16414
718569261384
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
15188
diff
changeset
|
153 |
]. |
8657 | 154 |
]. |
18302
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
155 |
searchClass isNil ifTrue:[ |
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
156 |
searchClass := self receiver class. |
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
157 |
]. |
18302
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
158 |
searchClass notNil ifTrue:[ |
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
159 |
"displayString is better than 'cls name', |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
160 |
since it appends (obsolete) for outdated classes. |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
161 |
(this happens if you send messages to old instances |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
162 |
after changing a classes definition)" |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
163 |
|
18302
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
164 |
description := searchClass displayString. |
10446
21f13f605ff5
changed #description - take care if the classes displayString is not a String
Stefan Vogel <sv@exept.de>
parents:
8657
diff
changeset
|
165 |
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
|
166 |
description := '(** ???-class **)' |
21f13f605ff5
changed #description - take care if the classes displayString is not a String
Stefan Vogel <sv@exept.de>
parents:
8657
diff
changeset
|
167 |
]. |
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
168 |
] ifFalse:[ |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
169 |
description := '(** nil-class **)' |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
170 |
]. |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
171 |
sel := self selector. |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
172 |
sel class == Symbol ifTrue:[ |
13028 | 173 |
description := description , ' does not understand: ' , sel storeString. |
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
174 |
"/ description := sel, ' not understood by ' , description. |
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 |
"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
|
177 |
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
|
178 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
179 |
description := description , ' does not understand nonSymbol: ' , sel printString. |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
180 |
"/ description := sel printString, ' (nonSymbol) not understood by ' , description. |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
181 |
]. |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
182 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
183 |
^ description |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
184 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
185 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
186 |
" |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
187 |
2 foo:3 |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
188 |
2 perform:55 |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
189 |
nil // 2 |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
190 |
" |
13028 | 191 |
|
192 |
"Modified: / 19-08-2010 / 15:33:03 / cg" |
|
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
193 |
! ! |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
194 |
|
5976 | 195 |
!MessageNotUnderstood class methodsFor:'documentation'! |
196 |
||
197 |
version |
|
18302
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
198 |
^ '$Header: /cvs/stx/stx/libbasic/MessageNotUnderstood.st,v 1.15 2015-04-28 21:18:21 cg Exp $' |
13028 | 199 |
! |
200 |
||
201 |
version_CVS |
|
18302
67840a4affd1
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
18290
diff
changeset
|
202 |
^ '$Header: /cvs/stx/stx/libbasic/MessageNotUnderstood.st,v 1.15 2015-04-28 21:18:21 cg Exp $' |
5976 | 203 |
! ! |
15188
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
204 |
|
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
205 |
|
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
206 |
MessageNotUnderstood initialize! |