Kilon
Kilon

Reputation: 2002

How to find which was the wrong message in a Message Not Understood message?

I want to find the name of the message that triggered the MNU , how do I do that ?

For example if I do

Transcript explode . 

This will trigger a MNU because method explode does not exist but how do I find that the name of the message that triggered MNU is "explode" ?

Upvotes: 3

Views: 630

Answers (2)

Eliot Miranda
Eliot Miranda

Reputation: 291

Try this:

[Transcript explode] on: MessageNotUnderstood do: [:ex| ex message selector]

The exception's message is an instance of Message. It understands selector arguments etc.

Remember that the exception is an epiphenomenon. The VM actually sends doesNotUnderstand: aMessage when a message is not understood, and the doesNotUnderstand: method in Object raises the exception. The argument to doesNotUnderstand: is a message, and is of curse the same as that in the exception. That means you can implement your own doesNotUnderstand: message in your own class if you have special requirements.

Upvotes: 4

Stephan Eggermont
Stephan Eggermont

Reputation: 15917

If I DoIt that, I get a debugger. The title there is

MessageNotUnderstood: ThreadSafeTranscript>>explode

When I select the first element, I get to see the doesNotUnderstand: aMessage, where aMessage is the message

Upvotes: 3

Related Questions