Created
November 15, 2013 19:00
-
-
Save abinoam/7489732 to your computer and use it in GitHub Desktop.
In response to https://www.ruby-forum.com/topic/4418571
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
#!/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