Hello,

I found method doesNotUnderstand have very strange implementation

Object>>doesNotUnderstand: aMessage
      | exception resumeValue |
    (exception := MessageNotUnderstood new)
        message: aMessage;
        receiver: self.
    resumeValue := exception signal.
    ^exception reachedDefaultHandler
        ifTrue: [aMessage sentTo: self]
        ifFalse: [resumeValue]

When Error has no handlers #defaultAction is executed. For
MessageNotUnderstood #defaultAction is UnhandledError signal. And for
UnhandledError #defaultAction is opening debugger.
If you change it to do nothing (^self) you get infinite loop on any
MessageNotUnderstood signal.
It is because "ifTrue" branch executed in doesNotUnderstood method and
message resend to receiver.

Why method implemented such way? Why it is differ from ProtoObject
implementation. I think It's bug implementation.

I found this problem when I try implement stuff to turn off openning
debugger on unhandled error (and write it to log)

UnhandledError>>defaultAction
    "The current computation is terminated. The cause of the error should be
logged or reported to the user. If the program is operating in an
interactive debugging environment the computation should be suspended and
the debugger activated."
    ^ToolSet debugError: exception.

ToolSet class>>debugError: anError
    "Handle an otherwise unhandled error"
    self default ifNil:[ | ctx |
        Smalltalk
            logError: anError description
            inContext: (ctx := anError signalerContext)
            to: 'PharoDebug.log'.
        self inform: (anError description, String cr, ctx shortStack).
        ^anError return].
    ^self default debugError: anError

I just implement subclass of StandartToolSet with empty method #debugError:.
Then I do "ToolSet default: MyToolSet". And now unhandled errors raise
infinit loop and never return.

I fix that by:

MyToolSet>>debugError: anError
   anError class = MessageNotUnderstand ifTrue: [anError
reachedDefaultHandler: true].

I think this is hack. But it is work. No errors show to user.And all work
good.

What do you think?

Best regards,
Denis
_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to