Return JSON response on http error