Google Groups Home
Help | Sign in
A way to access the last error raised (outside of a rescue block)
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
doug livesey  
View profile
 More options 18 Jul, 10:23
From: "doug livesey" <biot...@gmail.com>
Date: Fri, 18 Jul 2008 10:23:05 +0100
Local: Fri 18 Jul 2008 10:23
Subject: A way to access 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.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
doug livesey  
View profile
 More options 18 Jul, 14:18
From: "doug livesey" <biot...@gmail.com>
Date: Fri, 18 Jul 2008 14:18:23 +0100
Local: Fri 18 Jul 2008 14:18
Subject: Re: A way to access the last error raised (outside of a rescue block)

Oh, grief.The answer, of course, is this:
  result = my_method rescue $!.my_other_method

I'd love to tell you I took the natural next step myself & solved, but no.
A nice gentleperson on the Ruby forum sent it me, and was even nice enough
not to mention how dense I am.
Cheers,
   Doug.

2008/7/18 doug livesey <biot...@gmail.com>:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google