author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 26 Apr 2010 19:26:38 +0100 | |
branch | jv |
changeset 17761 | b0e5971141bc |
parent 17711 | 39faaaf888b4 |
child 17797 | 71451ae83564 |
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 |
|
6667 | 45 |
!MessageNotUnderstood class methodsFor:'save evaluation'! |
46 |
||
47 |
ignoreNotUnderstoodOf:aSelector in:aBlock |
|
48 |
"evaluate aBlock; if a messageNotUnderstood occurs, |
|
49 |
for which the message was aSelector, ignore the error |
|
50 |
and return. |
|
51 |
Other selector errors lead into the debugger. |
|
52 |
If no error occurs, return the blocks value" |
|
53 |
||
54 |
^ self handle:[:ex | |
|
6669 | 55 |
ex selector == aSelector ifFalse:[ |
6667 | 56 |
ex reject |
57 |
] |
|
58 |
] do:aBlock. |
|
6668 | 59 |
! |
60 |
||
61 |
ignoreNotUnderstoodOfAny:aCollectionOfSelectors in:aBlock |
|
62 |
"evaluate aBlock; if a messageNotUnderstood occurs, |
|
63 |
for which the message was any in aCollectionOfSelectors, 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 |
(aCollectionOfSelectors includesIdentical:ex selector) ifFalse:[ |
6668 | 70 |
ex reject |
71 |
] |
|
72 |
] do:aBlock. |
|
6667 | 73 |
! ! |
74 |
||
5982 | 75 |
!MessageNotUnderstood methodsFor:'accessing'! |
76 |
||
77 |
message |
|
78 |
^ parameter |
|
79 |
||
80 |
" |
|
81 |
[ |
|
82 |
123 perform:#foo |
|
83 |
] on:MessageNotUnderstood do:[:ex | |
|
84 |
Transcript show:'message object: '; showCR:ex message storeString. |
|
85 |
Transcript show:'receiver: '; showCR:ex receiver storeString. |
|
86 |
Transcript show:'selector: '; showCR:ex message selector storeString. |
|
87 |
Transcript show:'arguments: '; showCR:ex message arguments storeString. |
|
88 |
] |
|
89 |
" |
|
90 |
! |
|
91 |
||
92 |
receiver |
|
93 |
^ originator |
|
94 |
||
95 |
" |
|
96 |
[ |
|
97 |
123 perform:#foo |
|
98 |
] on:MessageNotUnderstood do:[:ex | |
|
99 |
Transcript showCR:ex receiver |
|
100 |
] |
|
101 |
" |
|
6668 | 102 |
! |
103 |
||
104 |
selector |
|
105 |
^ parameter selector |
|
106 |
||
107 |
" |
|
108 |
[ |
|
109 |
123 perform:#foo |
|
110 |
] on:MessageNotUnderstood do:[:ex | |
|
111 |
Transcript show:'selector: '; showCR:ex selector storeString. |
|
112 |
] |
|
113 |
" |
|
5982 | 114 |
! ! |
115 |
||
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
116 |
!MessageNotUnderstood methodsFor:'printing & storing'! |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
117 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
118 |
description |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
119 |
"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
|
120 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
121 |
|cls sel description| |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
122 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
123 |
"extract the class that should have implemented the message. |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
124 |
(in case of a super-send, this is not the receivers class)" |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
125 |
|
8657 | 126 |
suspendedContext notNil ifTrue:[ |
127 |
cls := suspendedContext sender searchClass. |
|
128 |
]. |
|
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
129 |
cls isNil ifTrue:[ |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
130 |
cls := self receiver class. |
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 |
cls notNil ifTrue:[ |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
133 |
"displayString is better than 'cls name', |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
134 |
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
|
135 |
(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
|
136 |
after changing a classes definition)" |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
137 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
138 |
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
|
139 |
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
|
140 |
description := '(** ???-class **)' |
21f13f605ff5
changed #description - take care if the classes displayString is not a String
Stefan Vogel <sv@exept.de>
parents:
8657
diff
changeset
|
141 |
]. |
8501
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
142 |
] ifFalse:[ |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
143 |
description := '(** nil-class **)' |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
144 |
]. |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
145 |
sel := self selector. |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
146 |
sel class == Symbol ifTrue:[ |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
147 |
description := description , ' does not understand: #' , sel. |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
148 |
"/ description := sel, ' not understood by ' , description. |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
149 |
] ifFalse:[ |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
150 |
"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
|
151 |
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
|
152 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
153 |
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
|
154 |
"/ 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
|
155 |
]. |
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 |
^ description |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
158 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
159 |
|
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
160 |
" |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
161 |
2 foo:3 |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
162 |
2 perform:55 |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
163 |
nil // 2 |
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 |
! ! |
8e114640aa5c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7586
diff
changeset
|
166 |
|
5976 | 167 |
!MessageNotUnderstood class methodsFor:'documentation'! |
168 |
||
169 |
version |
|
17761
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
170 |
^ '$Id: MessageNotUnderstood.st 10517 2010-04-26 18:26:38Z vranyj1 $' |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
171 |
! |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
172 |
|
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
173 |
version_SVN |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
174 |
^ '$Id: MessageNotUnderstood.st 10517 2010-04-26 18:26:38Z vranyj1 $' |
5976 | 175 |
! ! |