return json for errors