Catching Invalid JSON Parse Errors with Rack Middleware
The middleware in Rails that parses parameters (ActionDispatch::ParamsParser) runs long before your controller is on the scene, and throws exceptions when invalid JSON is encountered. Fortunately, it’s easy to write custom middleware that rescues the errors thrown when JSON can’t be parsed.
Post a comment