Skip to content

Instantly share code, notes, and snippets.

@kenjij
Created January 29, 2022 00:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenjij/74b753c2a97f35f9231f6d75fdb6bb34 to your computer and use it in GitHub Desktop.
Save kenjij/74b753c2a97f35f9231f6d75fdb6bb34 to your computer and use it in GitHub Desktop.
Exception handling in Ruby
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