Last active
February 5, 2016 21:39
-
-
Save philmill/99a2e2d727e1e801dbf1 to your computer and use it in GitHub Desktop.
Ruby: Begin Rescue Ensure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
# something which might raise an exception | |
rescue SomeExceptionClass => some_variable | |
# code that deals with some exception | |
rescue SomeOtherException => some_other_variable | |
# code that deals with some other exception | |
else | |
# code that runs only if *no* exception was raised | |
ensure | |
# ensure that this code always runs, no matter what | |
end | |
# http://stackoverflow.com/a/2192010 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment