MessageNotUnderstood.st
changeset 24592 b003befd8100
parent 24111 2c17f738ce20
equal deleted inserted replaced
24591:2efa5f69125c 24592:b003befd8100
   132 !MessageNotUnderstood methodsFor:'printing & storing'!
   132 !MessageNotUnderstood methodsFor:'printing & storing'!
   133 
   133 
   134 description
   134 description
   135     "the human readable description of the exception"
   135     "the human readable description of the exception"
   136 
   136 
   137     |searchClass sel description sender|
   137     |rcvr searchClass sel description sender|
   138 
   138 
   139     "extract the class that should have implemented the message.
   139     "extract the class that should have implemented the message.
   140      (in case of a super-send, this is not the receiver's class)"
   140      (in case of a super-send, this is not the receiver's class)"
   141 
   141 
   142     "/ suspendedContext is the actual doesNotUnderstand context;
   142     "/ suspendedContext is the actual doesNotUnderstand context;
   152             sender receiver == suspendedContext receiver ifTrue:[
   152             sender receiver == suspendedContext receiver ifTrue:[
   153                 searchClass := sender searchClass.
   153                 searchClass := sender searchClass.
   154             ].
   154             ].
   155         ].
   155         ].
   156     ].
   156     ].
       
   157     rcvr := self receiver.
   157     searchClass isNil ifTrue:[
   158     searchClass isNil ifTrue:[
   158         searchClass := self receiver class.
   159         searchClass := rcvr class.
   159     ].
   160     ].
       
   161 
   160     searchClass notNil ifTrue:[
   162     searchClass notNil ifTrue:[
   161         "displayString is better than 'cls name',
   163         "displayString is better than 'cls name',
   162          since it appends (obsolete) for outdated classes
   164          since it appends (obsolete) for outdated classes
   163          (this happens if you send messages to old instances
   165          (this happens if you send messages to old instances
   164           after changing a classes definition),
   166           after changing a classes definition),
   165          and may be also redefined for non-Smalltalk object (i.e. BridgeObjects)"
   167          and may be also redefined for non-Smalltalk object (i.e. BridgeObjects)"
   166 
   168 
   167         searchClass == self receiver class ifTrue:[
   169         searchClass == rcvr class ifTrue:[
   168             description := self receiver classDisplayString.
   170             description := rcvr classDisplayString.
   169         ] ifFalse:[
   171         ] ifFalse:[
   170             description := searchClass displayString.
   172             description := searchClass displayString.
   171         ].
   173         ].
   172         description isString ifFalse:[
   174         description isString ifFalse:[
   173             description := '(** ???-class **)'
   175             description := '(** ???-class **)'
   175     ] ifFalse:[    
   177     ] ifFalse:[    
   176         description := '(** nil-class **)'
   178         description := '(** nil-class **)'
   177     ].
   179     ].
   178     sel := self selector.
   180     sel := self selector.
   179     sel class == Symbol ifTrue:[
   181     sel class == Symbol ifTrue:[
   180         self receiver isNil ifTrue:[
   182         rcvr isNil ifTrue:[
   181             description := 'receiver of "',sel printString,'" is nil'.
   183             description := 'receiver of "',sel printString,'" is nil'.
   182         ] ifFalse:[    
   184         ] ifFalse:[
   183             (searchClass notNil and:[self receiver isBridgeProxy not and:[searchClass programmingLanguage isSmalltalk]]) ifTrue:[
   185             (searchClass notNil and:[rcvr isBridgeProxy not and:[searchClass programmingLanguage isSmalltalk]]) ifTrue:[
   184                 description := description , ' does not understand: "',sel,'"'.
   186                 description := description , ' does not understand: "',sel,'"'.
   185                 "/ description := sel, ' not understood by ' ,  description.
   187                 "/ description := sel, ' not understood by ' ,  description.
   186             ] ifFalse:[ 
   188             ] ifFalse:[ 
   187                 description := description , ' does not implement: ' , sel.
   189                 description := description , ' does not implement: ' , sel.
   188             ].
   190             ].
   190     ] ifFalse:[
   192     ] ifFalse:[
   191         "a non-symbol selector may happen when things go mad in a primitive, 
   193         "a non-symbol selector may happen when things go mad in a primitive, 
   192          or a method has been called by #perform: or #valueWithReceiver: with a wrong arg."
   194          or a method has been called by #perform: or #valueWithReceiver: with a wrong arg."
   193 
   195 
   194         "/ assume that it might be ok with other prog. languages
   196         "/ assume that it might be ok with other prog. languages
   195         (searchClass notNil and:[self receiver isBridgeProxy not and:[searchClass programmingLanguage isSmalltalk]]) ifTrue:[
   197         (searchClass notNil and:[rcvr isBridgeProxy not and:[searchClass programmingLanguage isSmalltalk]]) ifTrue:[
   196             description := description , ' does not understand (nonSymbol): ' , sel printString.
   198             description := description , ' does not understand (nonSymbol): ' , sel printString.
   197             "/ description := sel printString, ' (nonSymbol) not understood by ' ,  description.
   199             "/ description := sel printString, ' (nonSymbol) not understood by ' ,  description.
   198         ] ifFalse:[
   200         ] ifFalse:[
   199             description := description , ' does not implement: ' , sel printString.
   201             description := description , ' does not implement: ' , sel printString.
   200         ].
   202         ].