ben-v
February 7, 2010, 11:33pm
1
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
ben-v
February 8, 2010, 12:44am
2
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?
ben-v
February 8, 2010, 12:46am
3
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?
ben-v
February 8, 2010, 2:34am
4
El Lunes, 8 de Febrero de 2010, Ben V. escribió:
Does the rescue clause catch everything if no
error is provided?
Yes.
ben-v
February 8, 2010, 2:43am
5
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.
ben-v
February 8, 2010, 2:44am
6
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
ben-v
February 8, 2010, 2:57am
7
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.
ben-v
February 8, 2010, 3:19am
8
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.
ben-v
February 8, 2010, 6:10am
9
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.
ben-v
February 8, 2010, 3:00am
10
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