Created
September 6, 2009 09:41
-
-
Save kares/181736 to your computer and use it in GitHub Desktop.
action pack request exception patching for the pre 2.3 era
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
# Patch request to receive exceptions from body parsing (e.g. XML parsing) | |
ActionController::AbstractRequest.class_eval do | |
alias_method :parse_formatted_request_parameters_unsafely, :parse_formatted_request_parameters | |
def parse_formatted_request_parameters | |
begin | |
parse_formatted_request_parameters_unsafely #super | |
rescue Exception => e # YAML, XML or Ruby code block errors | |
self.env['EXCEPTION'] = e # there will be a before filter to check for this and re-raise | |
{ #"body" => raw_post, | |
"content_type" => content_type_with_parameters, "content_length" => content_length } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment