How to use the evasdk.eva_errors.EvaValidationError function in evasdk

To help you get started, we’ve selected a few evasdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github automata-tech / eva_python_sdk / evasdk / eva_errors.py View on Github external
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)