On 13.06.2008 21:58, Misiek Sz wrote:
> Is is possible to raise an exception then rescue it and then go back to
> whereever it was raised and continue with execution?
> For example,
> class Test
> end
> 
> begin
> code line 1
> code line 2
> code line 3
> code line 4
> code line 5
> raise Class.new
> code line 7
> code line 8
> code line 9
> 
> rescue Class
>  #here in some cases send back execution to code line 7
> 
> ensure
> end

There is no way - and for good reason.  An exception is thrown because 
execution cannot proceed at that line.

There is however retry, but it will continue from the beginning of the 
block:

irb(main):001:0> i = 0
=> 0
irb(main):002:0> begin
irb(main):003:1* puts 1
irb(main):004:1> raise "Foo"
irb(main):005:1> rescue Exception
irb(main):006:1> puts 2
irb(main):007:1> i += 1
irb(main):008:1> retry if i < 3
irb(main):009:1> end
1
2
1
2
1
2
=> nil
irb(main):010:0>

Kind regards

	robert