Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __parse_json(self, client):
try:
if (self.__is_json()):
result = json.loads(self.body)
self.parsed = True
return result
else:
return None
except Exception:
self.__raise_error(ParserError, client)
def error_for(self, status_code, parsed): # noqa: C901
if status_code is None:
return NetworkError
if status_code >= 500:
return ServerError
if status_code == 401:
return AuthenticationError
if status_code == 404:
return NotFoundError
if status_code >= 400:
return ClientError
if not parsed:
return ParserError