Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View exception_for_saurav.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#!/usr/bin/env ruby
 
def the_main_script
# Your main script
# Do whatever here
x = rand(3)
puts "x = #{x}"
puts "and 10/#{x} = #{10/x}" # When x==0 ZeroDivisionError
end
 
begin
the_main_script
rescue => exception_detail
p exception_detail.inspect
p exception_detail.message
p exception_detail.backtrace
puts exception_detail.backtrace.join("\n")
else
puts "Everything went ok"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.