Skip to content

Instantly share code, notes, and snippets.

@banyan
Created October 11, 2012 01:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save banyan/3869700 to your computer and use it in GitHub Desktop.
Save banyan/3869700 to your computer and use it in GitHub Desktop.
def bar
raise NoMemoryError
rescue puts "hi"
end
bar # Exception は補足できない
# /Users/kohei/lang/ruby/exception.rb:3:in `foo': NoMemoryError (NoMemoryError)
# from /Users/kohei/lang/ruby/exception.rb:8:in `<main>'
def foo
raise StandardError
rescue
puts "hi"
end
foo # => hi が出力される、補足できるのは StandardError とそのサブクラスのみ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment