RosettaCodeData/Task/Exceptions/Ruby/exceptions-4.rb

16 lines
230 B
Ruby
Raw Permalink Normal View History

2013-04-10 16:57:12 -07:00
begin
foo
rescue ArgumentError => e
# rescues a MyInvalidArgument or any other ArgumentError
bar
rescue => e
# rescues a StandardError
quack
else
# runs if no exception occurred
quux
ensure
# always runs
baz
end