author | Claus Gittinger <cg@exept.de> |
Fri, 09 May 2014 15:06:50 +0200 | |
changeset 16414 | 718569261384 |
parent 15188 | e1937381139c |
child 18120 | e3a375d5f6a8 |
child 18290 | 5ea0b888d79d |
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 |
||
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
14 |
ProceedableError subclass:#MessageNotUnderstood |
5976 | 15 |
instanceVariableNames:'' |
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
6210
d7039e2ae776
caetgory change and documentation added
Claus Gittinger <cg@exept.de>
parents:
5982
diff
changeset
|
18 |
category:'Kernel-Exceptions-Errors' |
5976 | 19 |
! |
20 |
||
6210
d7039e2ae776
caetgory change and documentation added
Claus Gittinger <cg@exept.de>
parents:
5982
diff
changeset
|
21 |
!MessageNotUnderstood class methodsFor:'documentation'! |
d7039e2ae776
caetgory change and documentation added
Claus Gittinger <cg@exept.de>
parents:
5982
diff
changeset
|
22 |
|
7586 | 23 |
copyright |
24 |
" |
|
25 |
COPYRIGHT (c) 2001 by eXept Software AG |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
6210
d7039e2ae776
caetgory change and documentation added
Claus Gittinger <cg@exept.de>
parents:
5982
diff
changeset
|
37 |
documentation |
d7039e2ae776
caetgory change and documentation added
Claus Gittinger <cg@exept.de>
parents:
5982
diff
changeset
|
38 |
" |
d7039e2ae776
caetgory change and documentation added
Claus Gittinger <cg@exept.de>
parents:
5982
diff
changeset
|
39 |
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
|
40 |
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
|
41 |
doesNotUnderstand: handler. |
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 |
! ! |
5976 | 44 |
|
15188
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
45 |
!MessageNotUnderstood class methodsFor:'initialization'! |
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
46 |
|
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
47 |
initialize |
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
48 |
NotifierString := 'message not understood'. |
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
49 |
|
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 |
self initialize |
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 |
! ! |
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
54 |
|
6667 | 55 |
!MessageNotUnderstood class methodsFor:'save evaluation'! |
56 |
||
57 |
ignoreNotUnderstoodOf:aSelector in:aBlock |
|
58 |
"evaluate aBlock; if a messageNotUnderstood occurs, |
|
59 |
for which the message was aSelector, ignore the error |
|
60 |
and return. |
|
61 |
Other selector errors lead into the debugger. |
|
62 |
If no error occurs, return the blocks value" |
|
63 |
||
64 |
^ self handle:[:ex | |
|
6669 | 65 |
ex selector == aSelector ifFalse:[ |
6667 | 66 |
ex reject |
67 |
] |
|
68 |
] do:aBlock. |
|
6668 | 69 |
! |
70 |
||
71 |
ignoreNotUnderstoodOfAny:aCollectionOfSelectors in:aBlock |
|
72 |
"evaluate aBlock; if a messageNotUnderstood occurs, |
|
73 |
for which the message was any in aCollectionOfSelectors, ignore the error |
|
74 |
and return. |
|
75 |
Other selector errors lead into the debugger. |
|
76 |
If no error occurs, return the blocks value" |
|
77 |
||
78 |
^ self handle:[:ex | |
|
6669 | 79 |
(aCollectionOfSelectors includesIdentical:ex selector) ifFalse:[ |
6668 | 80 |
ex reject |
81 |
] |
|
82 |
] do:aBlock. |
|
6667 | 83 |
! ! |
84 |
||
5982 | 85 |
!MessageNotUnderstood methodsFor:'accessing'! |
86 |
||
87 |
message |
|
88 |
^ parameter |
|
89 |
||
90 |
" |
|
91 |
[ |
|
92 |
123 perform:#foo |
|
93 |
] on:MessageNotUnderstood do:[:ex | |
|
94 |
Transcript show:'message object: '; showCR:ex message storeString. |
|
95 |
Transcript show:'receiver: '; showCR:ex receiver storeString. |
|
96 |
Transcript show:'selector: '; showCR:ex message selector storeString. |
|
97 |
Transcript show:'arguments: '; showCR:ex message arguments storeString. |
|
98 |
] |
|
99 |
" |
|
100 |
! |
|
101 |
||
102 |
receiver |
|
103 |
^ originator |
|
104 |
||
105 |
" |
|
106 |
[ |
|
107 |
123 perform:#foo |
|
108 |
] on:MessageNotUnderstood do:[:ex | |
|
109 |
Transcript showCR:ex receiver |
|
110 |
] |
|
111 |
" |
|
6668 | 112 |
! |
113 |
||
114 |
selector |
|
115 |
^ parameter selector |
|
116 |
||
117 |
" |
|
118 |
[ |
|
119 |
123 perform:#foo |
|
120 |
] on:MessageNotUnderstood do:[:ex | |
|
121 |
Transcript show:'selector: '; showCR:ex selector storeString. |
|
122 |
] |
|
123 |
" |
|
5982 | 124 |
! ! |
125 |
||
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
126 |
!MessageNotUnderstood methodsFor:'printing & storing'! |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
127 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
128 |
description |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
129 |
"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
|
130 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
131 |
|cls sel description| |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
132 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
133 |
"extract the class that should have implemented the message. |
16414
718569261384
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
15188
diff
changeset
|
134 |
(in case of a super-send, this is not the receiver's class)" |
8657 | 135 |
suspendedContext notNil ifTrue:[ |
16414
718569261384
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
15188
diff
changeset
|
136 |
cls := suspendedContext searchClass. |
718569261384
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
15188
diff
changeset
|
137 |
suspendedContext sender notNil ifTrue:[ |
718569261384
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
15188
diff
changeset
|
138 |
cls := suspendedContext sender searchClass. |
718569261384
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
15188
diff
changeset
|
139 |
]. |
8657 | 140 |
]. |
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
141 |
cls isNil ifTrue:[ |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
142 |
cls := self receiver class. |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
143 |
]. |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
144 |
cls notNil ifTrue:[ |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
145 |
"displayString is better than 'cls name', |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
146 |
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
|
147 |
(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
|
148 |
after changing a classes definition)" |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
149 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
150 |
description := cls displayString. |
10446
21f13f605ff5
changed #description - take care if the classes displayString is not a String
Stefan Vogel <sv@exept.de>
parents:
8657
diff
changeset
|
151 |
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
|
152 |
description := '(** ???-class **)' |
21f13f605ff5
changed #description - take care if the classes displayString is not a String
Stefan Vogel <sv@exept.de>
parents:
8657
diff
changeset
|
153 |
]. |
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
154 |
] ifFalse:[ |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
155 |
description := '(** nil-class **)' |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
156 |
]. |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
157 |
sel := self selector. |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
158 |
sel class == Symbol ifTrue:[ |
13028 | 159 |
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
|
160 |
"/ description := sel, ' not understood by ' , description. |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
161 |
] ifFalse:[ |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
162 |
"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
|
163 |
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
|
164 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
165 |
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
|
166 |
"/ 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
|
167 |
]. |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
168 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
169 |
^ description |
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 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
172 |
" |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
173 |
2 foo:3 |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
174 |
2 perform:55 |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
175 |
nil // 2 |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
176 |
" |
13028 | 177 |
|
178 |
"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
|
179 |
! ! |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
180 |
|
5976 | 181 |
!MessageNotUnderstood class methodsFor:'documentation'! |
182 |
||
183 |
version |
|
16414
718569261384
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
15188
diff
changeset
|
184 |
^ '$Header: /cvs/stx/stx/libbasic/MessageNotUnderstood.st,v 1.13 2014-05-09 13:06:50 cg Exp $' |
13028 | 185 |
! |
186 |
||
187 |
version_CVS |
|
16414
718569261384
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
15188
diff
changeset
|
188 |
^ '$Header: /cvs/stx/stx/libbasic/MessageNotUnderstood.st,v 1.13 2014-05-09 13:06:50 cg Exp $' |
5976 | 189 |
! ! |
15188
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
190 |
|
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
191 |
|
e1937381139c
class: MessageNotUnderstood
Claus Gittinger <cg@exept.de>
parents:
13028
diff
changeset
|
192 |
MessageNotUnderstood initialize! |