public
Created

  • Download Gist
exception_for_saurav.rb
Ruby
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.