Skip to content

Instantly share code, notes, and snippets.

@jhjguxin
Created June 19, 2012 03:17
Show Gist options
  • Save jhjguxin/2952108 to your computer and use it in GitHub Desktop.
Save jhjguxin/2952108 to your computer and use it in GitHub Desktop.
ruby Exception catch
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment