Update 400, 403, 404 handling
Replace ValueError by InvalidRequestError
Add handling of InvalidRequestError in ``to_python`