Skip to content

Instantly share code, notes, and snippets.

@abinoam
Created November 15, 2013 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abinoam/7489732 to your computer and use it in GitHub Desktop.
Save abinoam/7489732 to your computer and use it in GitHub Desktop.
#!/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