Skip to content

Instantly share code, notes, and snippets.

@sandro
Created October 11, 2010 13:08
Show Gist options
  • Save sandro/620478 to your computer and use it in GitHub Desktop.
Save sandro/620478 to your computer and use it in GitHub Desktop.
module ActionDispatch
class ShowExceptions
private
def original_exception(exception)
if registered_original_exception?(exception)
exception.original_exception
else
exception
end
end
def registered_original_exception?(exception)
exception.respond_to?(:original_exception) && @@rescue_responses.has_key?(exception.original_exception.class.name)
end
def rescue_action_locally_with_original_exception(request, exception)
rescue_action_locally_without_original_exception(request, original_exception(exception))
end
alias_method_chain :rescue_action_locally, :original_exception
def rescue_action_in_public_with_original_exception(exception)
rescue_action_in_public_without_original_exception(original_exception(exception))
end
alias_method_chain :rescue_action_in_public, :original_exception
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment