module ActiveSupport::Rescuable

def rescue_with_handler(exception)

Tries to rescue the exception by looking up and calling a registered handler.
def rescue_with_handler(exception)
  if handler = handler_for_rescue(exception)
    handler.arity != 0 ? handler.call(exception) : handler.call
    true # don't rely on the return value of the handler
  end
end