begin rescue else end

For example,

begin
# Your normal code block here…

rescue SomeException
# handle your exception here…

else
# code run if it did not throw an exception

ensure
# This is the last thing to be run before it exits.
# Code in the ensure clause will always get executed.

end

Leave a Reply

Your email address will not be published. Required fields are marked *