How to use the smartcar.exceptions function in smartcar

To help you get started, we’ve selected a few smartcar 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 smartcar / python-sdk / smartcar / requester.py View on Github external
raise E.AuthenticationException(response)
    elif code == 403:
        raise E.PermissionException(response)
    elif code == 404:
        raise E.ResourceNotFoundException(response)
    elif code == 409:
        raise E.StateException(response)
    elif code == 429:
        raise E.RateLimitingException(response)
    elif code == 430:
        raise E.MonthlyLimitExceeded(response)
    elif code == 500:
        raise E.ServerException(response)
    elif code == 501:
        if body['error'] == 'smartcar_not_capable_error':
            raise E.SmartcarNotCapableException(response)
        raise E.VehicleNotCapableException(response)
    elif code == 504:
        raise E.GatewayTimeoutException(response)
    else:
        response.raise_for_status()
github smartcar / python-sdk / smartcar / requester.py View on Github external
kwargs['headers'] = {}
    kwargs['headers']['User-Agent'] = 'Smartcar/{} ({}; {}) Python v{}'.format(
        __version__,
        platform.system(),
        platform.machine(),
        platform.python_version()
    )

    response = requests.request(method, url, timeout=300, **kwargs)
    code = response.status_code
    body = response.json()

    if response.ok:
        return response
    elif code == 400:
        raise E.ValidationException(response)
    elif code == 401:
        raise E.AuthenticationException(response)
    elif code == 403:
        raise E.PermissionException(response)
    elif code == 404:
        raise E.ResourceNotFoundException(response)
    elif code == 409:
        raise E.StateException(response)
    elif code == 429:
        raise E.RateLimitingException(response)
    elif code == 430:
        raise E.MonthlyLimitExceeded(response)
    elif code == 500:
        raise E.ServerException(response)
    elif code == 501:
        if body['error'] == 'smartcar_not_capable_error':