Paul Rogers
4/24/2007 2:50:00 PM
On Apr 23, 9:42 pm, james.d.mast...@gmail.com wrote:
> On Apr 23, 8:29 pm, Paul Rogers <pmr16...@gmail.com> wrote:
>
> > > > Thanks, I actually wanted to see what the last exception was out side
> > > > of a block, kind of like this
> > > > begin
> > > > raise "bad"
> > > > rescue => e
> > > > puts "#{e} was raised"
> > > > end
> > > > puts "Just to make sure, last exception was #{$!}"
>
> If you don't have your heart set on using $!, then just put the
> contents into a variable (code not tested):
>
> last_error = nil
> begin
> raise "bad"
> rescue => e
> last_error = e
> end
>
> puts "An error was encountered: #{e}" if e
The reason I have to do this, and why $! was so attractive is that I
have many rescue blocks scattered throughout the code, which Im trying
to fix up, but I dont want to do them all at once, so just seeing the
last exception, was going to be helpful. I have another work around
that isnt as nice as $! appeared to be, but it does enough for what I
need
Thanks for all your help
Paul