Ruby’s try{ catch } block
Ruby October 16th, 2007As are many posts on this blog, this one is just a reminder for myself and anyone else who can’t remember the ruby equivalent of a try/catch block and has had to Google it several times because their memory sucks:
begin
…
rescue
…
end
Now next time I Google it I won’t have to sift through 10 articles.








October 20th, 2007 at 4:36 am
being
…
rescue
…
else
…
ensure
…
end
Something else to google about
December 28th, 2007 at 11:58 am
I want to meet the person in ruby who came up with this idea of naming them as begin.. rescue… end.
Thats one frantic whose siter would make it to every ruby programmers most dirty dreams.
June 9th, 2008 at 3:52 pm
Hey an important missing piece is that you want:
begin
# something potentially bad
rescue Exception=>e
# handle e
end
I have done this with a require that wasn’t available and it
wouldn’t work without the Exception=>e
Of course Exception should be fine tuned to the Exception
you are checking for.