Rescue Block does not work

Hi all,

I am using a begin.. rescue.. else block to catch a timeout and try
again until it succeeds. Despite the rescue block, the program still
crashes due to a timeout error. Don't rescue blocks catch everything?

success = false
    while success == false
      begin
        output2 = exportForm.click_button(exportForm.buttons[3])
      rescue Timeout::Error
        output "Timeout.. waiting 5s then trying again"
        sleep(5)
      else
        success = true
      end
    end

Thanks,

Ben

···

--
Posted via http://www.ruby-forum.com/.

Are you sure which is the exact exception raised?

···

El Domingo, 7 de Febrero de 2010, Ben Vishny escribió:

Hi all,

I am using a begin.. rescue.. else block to catch a timeout and try
again until it succeeds. Despite the rescue block, the program still
crashes due to a timeout error. Don't rescue blocks catch everything?

success = false
    while success == false
      begin
        output2 = exportForm.click_button(exportForm.buttons[3])
      rescue Timeout::Error
        output "Timeout.. waiting 5s then trying again"
        sleep(5)
      else
        success = true
      end
    end

--
Iñaki Baz Castillo <ibc@aliax.net>

Iñaki Baz Castillo wrote:

···

El Domingo, 7 de Febrero de 2010, Ben Vishny escribió:

      rescue Timeout::Error
        output "Timeout.. waiting 5s then trying again"
        sleep(5)
      else
        success = true
      end
    end

Are you sure which is the exact exception raised?

My mistake. I originally had a generic rescue clause without the
Timeout::Error and it was still erroring out - I tried this to see if it
would make a difference. Does the rescue clause catch everything if no
error is provided?
--
Posted via http://www.ruby-forum.com/\.

Yes.

···

El Lunes, 8 de Febrero de 2010, Ben Vishny escribió:

Does the rescue clause catch everything if no
error is provided?

--
Iñaki Baz Castillo <ibc@aliax.net>

Hi,

···

In message "Re: Rescue Block does not work" on Mon, 8 Feb 2010 08:46:11 +0900, Ben Vishny <bvishny@gmail.com> writes:

Does the rescue clause catch everything if no
error is provided?

The rescue clause without explicit exception class catches any
subclass of StandardError.

              matz.

Yukihiro Matsumoto wrote:

Hi,

>Does the rescue clause catch everything if no
>error is provided?

The rescue clause without explicit exception class catches any
subclass of StandardError.

              matz.

Matz,

Does this mean that the rescue block doesn't work because the error I'm
trying to catch isn't part of StandardError?

Ben

···

In message "Re: Rescue Block does not work" > on Mon, 8 Feb 2010 08:46:11 +0900, Ben Vishny <bvishny@gmail.com> > writes:

--
Posted via http://www.ruby-forum.com/\.

Sorry, I was wrong as just StandardError inherit exceptions are rescued.

···

El Lunes, 8 de Febrero de 2010, Iñaki Baz Castillo escribió:

El Lunes, 8 de Febrero de 2010, Ben Vishny escribió:
> Does the rescue clause catch everything if no
> error is provided?

Yes.

--
Iñaki Baz Castillo <ibc@aliax.net>

Hi,

···

In message "Re: Rescue Block does not work" on Mon, 8 Feb 2010 10:45:27 +0900, Ben Vishny <bvishny@gmail.com> writes:

Does this mean that the rescue block doesn't work because the error I'm
trying to catch isn't part of StandardError?

On 1.8, Timeout::Error is a subclass of Interrupt, which is NOT a
subclass of StandardError. Explicitly specify the error to catch the
timeout.

              matz.

Yukihiro Matsumoto wrote:

Hi,

>Does this mean that the rescue block doesn't work because the error I'm
>trying to catch isn't part of StandardError?

On 1.8, Timeout::Error is a subclass of Interrupt, which is NOT a
subclass of StandardError. Explicitly specify the error to catch the
timeout.

              matz.

Matz,

Thanks so much! I'm using Timeout::Error now and having no problems. You
wrote one kick-ass language, btw.

Ben

···

In message "Re: Rescue Block does not work" > on Mon, 8 Feb 2010 10:45:27 +0900, Ben Vishny <bvishny@gmail.com> > writes:

--
Posted via http://www.ruby-forum.com/\.

Hi,

···

In message "Re: Rescue Block does not work" on Mon, 8 Feb 2010 11:00:28 +0900, Ben Vishny <bvishny@gmail.com> writes:

Thanks so much! I'm using Timeout::Error now and having no problems. You
wrote one kick-ass language, btw.

For the record, on 1.9 Timeout::Error is a subclass of StandardError.

              matz.