Use a modified begin/rescue

Marc Heiler wrote in post #1051488:

I could also use other methods perhaps, rather than begin, use something
like:

rescue_verbose {
  code_that_may_fail_here
}

def rescue_verbose
  yield
rescue => e
  puts e
end

rescue_verbose { 1 / 0 }

Note: you would be advised not to rescue Exception, but instead rescue
StandardError (which is the default if you don't specify a class).
Exception includes things you almost certainly don't want to rescue,
like SyntaxError, NoMemoryError, and Interrupt.

···

--
Posted via http://www.ruby-forum.com/\.