Module connectedcar.exceptions

Expand source code
import requests
class SyncException(Exception):

    def __init__(self, response):
        self.message = 'Unknown error'
        if type(response) is requests.models.Response:
            json = response.json()
            if 'message' in json:
                self.message = json['message']
            elif 'error_description' in json:
                self.message = json['error_description']
        elif type(response) is str:
            self.message = response

    def __str__(self):
        return self.message

class ValidationException(SyncException):
    pass

class AuthenticationException(SyncException):
    pass

class PermissionException(SyncException):
    pass

class ResourceNotFoundException(SyncException):
    pass

class RateLimitingException(SyncException):
    pass

class ServerException(SyncException):
    pass

class GatewayTimeoutException(SyncException):
    def __init__(self, response):
        self.message = response.text

    def __str__(self):
        return self.message

Classes

class AuthenticationException (response)

Common base class for all non-exit exceptions.

Expand source code
class AuthenticationException(SyncException):
    pass

Ancestors

class GatewayTimeoutException (response)

Common base class for all non-exit exceptions.

Expand source code
class GatewayTimeoutException(SyncException):
    def __init__(self, response):
        self.message = response.text

    def __str__(self):
        return self.message

Ancestors

class PermissionException (response)

Common base class for all non-exit exceptions.

Expand source code
class PermissionException(SyncException):
    pass

Ancestors

class RateLimitingException (response)

Common base class for all non-exit exceptions.

Expand source code
class RateLimitingException(SyncException):
    pass

Ancestors

class ResourceNotFoundException (response)

Common base class for all non-exit exceptions.

Expand source code
class ResourceNotFoundException(SyncException):
    pass

Ancestors

class ServerException (response)

Common base class for all non-exit exceptions.

Expand source code
class ServerException(SyncException):
    pass

Ancestors

class SyncException (response)

Common base class for all non-exit exceptions.

Expand source code
class SyncException(Exception):

    def __init__(self, response):
        self.message = 'Unknown error'
        if type(response) is requests.models.Response:
            json = response.json()
            if 'message' in json:
                self.message = json['message']
            elif 'error_description' in json:
                self.message = json['error_description']
        elif type(response) is str:
            self.message = response

    def __str__(self):
        return self.message

Ancestors

  • builtins.Exception
  • builtins.BaseException

Subclasses

class ValidationException (response)

Common base class for all non-exit exceptions.

Expand source code
class ValidationException(SyncException):
    pass

Ancestors