MessageNotUnderstood.st
changeset 8501 8e114640aa5c
parent 7586 63e4900c8931
child 8657 1df84e8daa15
equal deleted inserted replaced
8500:10d47cede03c 8501:8e114640aa5c
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
    13 "{ Package: 'stx:libbasic' }"
    13 "{ Package: 'stx:libbasic' }"
    14 
    14 
    15 Error subclass:#MessageNotUnderstood
    15 ProceedableError subclass:#MessageNotUnderstood
    16 	instanceVariableNames:''
    16 	instanceVariableNames:''
    17 	classVariableNames:''
    17 	classVariableNames:''
    18 	poolDictionaries:''
    18 	poolDictionaries:''
    19 	category:'Kernel-Exceptions-Errors'
    19 	category:'Kernel-Exceptions-Errors'
    20 !
    20 !
    39 "
    39 "
    40     raised when a message is sent to an object, which is not understood
    40     raised when a message is sent to an object, which is not understood
    41     by the receiver, and the message was not handled by a class specific
    41     by the receiver, and the message was not handled by a class specific
    42     doesNotUnderstand: handler.
    42     doesNotUnderstand: handler.
    43 "
    43 "
    44 ! !
       
    45 
       
    46 !MessageNotUnderstood class methodsFor:'queries'!
       
    47 
       
    48 mayProceed
       
    49     "Return true, because messageNotUnderstood is proceedable (with nil)."
       
    50 
       
    51     ^ true
       
    52 ! !
    44 ! !
    53 
    45 
    54 !MessageNotUnderstood class methodsFor:'save evaluation'!
    46 !MessageNotUnderstood class methodsFor:'save evaluation'!
    55 
    47 
    56 ignoreNotUnderstoodOf:aSelector in:aBlock
    48 ignoreNotUnderstoodOf:aSelector in:aBlock
   120         Transcript show:'selector: '; showCR:ex selector storeString.
   112         Transcript show:'selector: '; showCR:ex selector storeString.
   121      ]
   113      ]
   122     "
   114     "
   123 ! !
   115 ! !
   124 
   116 
       
   117 !MessageNotUnderstood methodsFor:'printing & storing'!
       
   118 
       
   119 description
       
   120     "the human readable description of the exception"
       
   121 
       
   122     |cls sel description|
       
   123 
       
   124     "extract the class that should have implemented the message.
       
   125      (in case of a super-send, this is not the receivers class)"
       
   126 
       
   127     cls := suspendedContext sender searchClass.
       
   128     cls isNil ifTrue:[
       
   129         cls := self receiver class.
       
   130     ].
       
   131     cls notNil ifTrue:[
       
   132         "displayString is better than 'cls name',
       
   133          since it appends (obsolete) for outdated classes.
       
   134          (this happens if you send messages to old instances
       
   135           after changing a classes definition)"
       
   136 
       
   137         description := cls displayString.
       
   138     ] ifFalse:[    
       
   139         description := '(** nil-class **)'
       
   140     ].
       
   141     sel := self selector.
       
   142     sel class == Symbol ifTrue:[
       
   143         description := description , ' does not understand: #' , sel.
       
   144         "/ description := sel, ' not understood by ' ,  description.
       
   145     ] ifFalse:[
       
   146         "a non-symbol selector may happen when things go mad in a primitive, 
       
   147          or a method has been called by #perform: or #valueWithReceiver: with a wrong arg."
       
   148 
       
   149         description := description , ' does not understand nonSymbol: ' , sel printString.
       
   150         "/ description := sel printString, ' (nonSymbol) not understood by ' ,  description.
       
   151     ].
       
   152 
       
   153     ^ description
       
   154 
       
   155 
       
   156     "
       
   157         2 foo:3
       
   158         2 perform:55
       
   159         nil // 2
       
   160     "
       
   161 ! !
       
   162 
   125 !MessageNotUnderstood class methodsFor:'documentation'!
   163 !MessageNotUnderstood class methodsFor:'documentation'!
   126 
   164 
   127 version
   165 version
   128     ^ '$Header: /cvs/stx/stx/libbasic/MessageNotUnderstood.st,v 1.7 2003-08-29 19:15:14 cg Exp $'
   166     ^ '$Header: /cvs/stx/stx/libbasic/MessageNotUnderstood.st,v 1.8 2004-08-30 18:02:37 stefan Exp $'
   129 ! !
   167 ! !