Created
January 29, 2022 00:21
-
-
Save kenjij/74b753c2a97f35f9231f6d75fdb6bb34 to your computer and use it in GitHub Desktop.
Exception handling in Ruby
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 | |
# do something bad | |
rescue => e # StandardError by default | |
puts "Exception class: #{ e.class.name }" | |
puts "Exception message: #{ e.message }" | |
puts "Exception backtrace: #{ e.backtrace }" | |
# Or just: puts "#{e}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment