05 Nov '13, 2pm

A nice solution to a common problem from Thoughtbot: "Catching Invalid JSON Parse Errors with Rack Middleware"

Catching Invalid JSON Parse Errors with Rack Middleware Dan Collis-Puro November 04, 2013 rails json There is a world where developers need never worry about poorly formatted JSON. This is not that world. If a client submits invalid / poorly formatted JSON to a rails 3.2 or 4 app, a cryptic and unhelpful error is thrown and they're left wondering why the request tanked. Example errors: The error thrown by the parameter parsing middleware behaves differently depending on your version of Rails: 3.2 throws a 500 error in HTML format (no matter what the client asked for in its Accepts: header), and 4.0 throws a 400 "Bad Request" error in the format the client specifies. Here's the default rails 3.2 error - not great. > curl -H "Accept: application/json" -H "Content-type: application/json" 'http://localhost:3000/posts' -d '{ i am broken' <!DOCTYPE html> <html> <!-- default 500 ...

Full article: http://robots.thoughtbot.com/catching-json-parse-errors-w...

Tweets

Catching Invalid JSON Parse Errors with Rack Mi...

robots.thoughtbot.com 04 Nov '13, 10pm

Catching Invalid JSON Parse Errors with Rack Middleware Dan Collis-Puro November 04, 2013 rails json There is a world wher...

Catching Invalid JSON Parse Errors with Rack Mi...

rubyflow.com 04 Nov '13, 11pm

Catching Invalid JSON Parse Errors with Rack Middleware Posted by croaky on November 05, 2013 — 0 comments The middleware ...

Quick Introduction to Rack”- This post is so awesome. #Rails

Quick Introduction to Rack”- This post is so aw...

rubylearning.com 05 Nov '13, 5pm

Rack is the foundation of a great majority of modern Ruby web frameworks. This common interface between web servers and we...

"blisteringly fast json"

robots.thoughtbot.com 04 Nov '13, 10am

Fast JSON APIs in Rails with Key-Based Caches and ActiveModel::Serializers Josh Clayton May 30, 2013 performance ruby on r...