Skip to content

Instantly share code, notes, and snippets.

@mitsuhirookuno
Created January 20, 2021 05:13
Show Gist options
  • Save mitsuhirookuno/01e6c46287cb10d6fa908b158bd304ab to your computer and use it in GitHub Desktop.
Save mitsuhirookuno/01e6c46287cb10d6fa908b158bd304ab to your computer and use it in GitHub Desktop.
Mysql2の例外のみ補足したい
def main(raise_class)
raise raise_class, 'try rescue!'
rescue Mysql2::Error
puts "catch #{$!}"
rescue
puts "Through #{$!}"
end
main(Mysql2::Error)
main(Mysql2::Error::TimeoutError)
main(Mysql2::Error::ConnectionError)
main(StandardError)
main(ArgumentError)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment