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