Accessing the last error raised outside of a rescue block

Hi – I want to be able to grab some details from an error, but not just
the message.
So I want a variable called result to be either the result of a method,
or a property of the error raised by that method.
If the property I wanted from the error was the message, then I could do
this like this:
result = my_method rescue $!

However, what I want to do is call a method on the error, like so:
result = my_method rescue last_error.my_other_method

Where last_error is the mysterious means I employ to get at the error
raised, and my_other_method is what I want to call on it.

Does anyone know if this is possible?
Cheers,
Doug.

Doug L. wrote:

result = my_method rescue $!

However, what I want to do is call a method on the error, like so:
result = my_method rescue last_error.my_other_method

Where last_error is the mysterious means I employ to get at the error
raised, and my_other_method is what I want to call on it.

The last time I tried to do anything with a rescue statement modifier
other than
replace its statements value, it didn’t work. However…

result = my_method rescue $!.my_other_method

Does that work?

Yup, that worked beautifully, cheers!
Now the scary question is “why on earth didn’t I try that?”
I’ve whittled it down to two possible answers, and the good news for you
is that you are a genius, because the alternative is that I’m a maroon,
and I’m not having that.
Cheers, man!
Doug.