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

El Domingo, 7 de Febrero de 2010, Ben V. 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?

Iñaki Baz C. wrote:

El Domingo, 7 de Febrero de 2010, Ben V. 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?

El Lunes, 8 de Febrero de 2010, Ben V. escribió:

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

Yes.

Hi,

In message “Re: Rescue Block does not work”
on Mon, 8 Feb 2010 08:46:11 +0900, Ben V. [email protected]
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 M. wrote:

Hi,

In message “Re: Rescue Block does not work”
on Mon, 8 Feb 2010 08:46:11 +0900, Ben V. [email protected]
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.

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

Hi,

In message “Re: Rescue Block does not work”
on Mon, 8 Feb 2010 10:45:27 +0900, Ben V. [email protected]
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.

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

El Lunes, 8 de Febrero de 2010, Ben V. escribió:

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

Yes.

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

Hi,

In message “Re: Rescue Block does not work”
on Mon, 8 Feb 2010 11:00:28 +0900, Ben V. [email protected]
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.

Yukihiro M. wrote:

Hi,

In message “Re: Rescue Block does not work”
on Mon, 8 Feb 2010 10:45:27 +0900, Ben V. [email protected]
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.

Matz,

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

Ben

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs