On Thu, 3 Nov 2005, Robert Klemme wrote:

> Hugh Sasse wrote:
> > On Thu, 3 Nov 2005, Robert Klemme wrote:
> >
> >> Hugh Sasse wrote:
> >>> I see my changes to fileutils are now in the Ruby CVS.
> >>> However, even with
> >>>   rescue Exception, SystemCallError => e
> >>> or
> >>>   rescue Exception, Errno::EACCES, Errno::EBUSY => e
> >>>
> >>> I still cannot trap this error.  From the call stack this part of
> >>> the code is being used, so why won't the error cause ruby to go back
> >>> up the callstack until it finds this rescue clause?
> >>
> >> Maybe there's another rescue clause that is closer to the place
> >> where the exception is thrown...
> >
> > But unless I have completely misunderstood the point of rescue, even
> > if that calls raise, the exception will still be caught by my
> > enclosing rescue.
> 
> But who guarantees that the other rescue clause actually throws again?  If
> it doesn't you can't catch it.
> 
> ....
> rescue Exception => e
>   puts "Catch me if you can >:-}"
> end
> 
> ;-)
> 

Then it's already caught, and I should never see the error.

neelix hgs 58 %> irb
irb(main):001:0> begin
irb(main):002:1*   begin
irb(main):003:2*     raise StandardError
irb(main):004:2>   rescue => e
irb(main):005:2>     puts "catch me if you can #{e}"
irb(main):006:2>   end
irb(main):007:1> rescue
irb(main):008:1>   puts "caught something"
irb(main):009:1> end
catch me if you can StandardError
=> nil
irb(main):010:0>

i.e. that's a normal exit.  

So, I have an error that is not already caught, and I can't catch
it.

> Cheers
> 
>     robert
> 

        Hugh