Created
March 5, 2013 07:54
-
-
Save gokure/5088676 to your computer and use it in GitHub Desktop.
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
# Custom error response of parse json | |
module MyApp | |
class ParamsParser < ::ActionDispatch::ParamsParser | |
def call(env) | |
super | |
rescue ::MultiJson::DecodeError | |
[400, {'Content-Type' => 'application/json'}, [{message: 'JSON parse error'}.to_json]] | |
end | |
end | |
end | |
MyApp::Application.config.middleware.insert_before ActionDispatch::ParamsParser, MyApp::ParamsParser |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment