Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __handle_http_error(label, r):
error_string = '{}: status code {}'.format(label, r.status_code)
try:
r_json = r.json()
if 'error' in r_json:
error_string += ' with error [{}]'.format(r_json)
except ValueError:
pass
if r.status_code == 401:
raise EvaValidationError(error_string)
elif r.status_code == 401:
raise EvaAuthError(error_string)
elif r.status_code == 403:
raise EvaAdminError(error_string)
elif 400 <= r.status_code < 500:
raise EvaError(error_string)
elif 500 <= r.status_code < 600:
raise EvaServerError(error_string)
else:
raise EvaError(error_string)