Modifed error object to become json response object