method

rescue_with_handler

Importance_1
v6.0.0 - Show latest stable - 0 notes - Class: ActiveSupport::Rescuable::ClassMethods
rescue_with_handler(exception, object: self, visited_exceptions: []) public

Matches an exception to a handler based on the exception class.

If no handler matches the exception, check for a handler matching the (optional) exception.cause. If no handler matches the exception or its cause, this returns nil, so you can deal with unhandled exceptions. Be sure to re-raise unhandled exceptions if this is what you expect.

begin
  …
rescue => exception
  rescue_with_handler(exception) || raise
end

Returns the exception if it was handled and nil if it was not.

Show source
Register or log in to add new notes.