Rails middleware to catch JSON parse errors and return error in JSON format