onboardapis.exceptions

Exceptions for the onboardapis package.

 1"""
 2Exceptions for the onboardapis package.
 3"""
 4from __future__ import annotations
 5
 6from restfly.errors import APIError
 7
 8
 9class OnboardException(Exception):
10    """Base exception class for on-board exceptions."""
11
12    __slots__ = ()
13
14
15class APIConnectionError(OnboardException, ConnectionError):
16    """Exception raised when an API connection error occurs."""
17
18    __slots__ = ()
19
20
21class InitialConnectionError(APIConnectionError):
22    """Exception raised only when the first try to connect to an API fails."""
23
24    __slots__ = ()
25
26    def __init__(self, message: str = "Unable to connect to the API, are you connected to the on-board Wi-Fi?", *args):
27        super(InitialConnectionError, self).__init__(message, *args)
28
29
30class DataInvalidError(APIConnectionError):
31    """Error raised when an API sends a response that could not be parsed
32    due to a formatting error or when the data is missing."""
33
34    __slots__ = ()
35
36    def __init__(self, message: str = "The API returned an invalid response", *args):
37        super(DataInvalidError, self).__init__(message, *args)
38
39
40class APIFeatureMissingError(APIConnectionError, APIError):
41    """Error raised when an API could support a feature,
42    but the actual implementation onboard this vehicle does not support this feature."""
43
44    __slots__ = ()
45
46    def __init__(self, resp, message: str = None, **kwargs):
47        if not message:
48            message = "The requested feature (%s) is not supported by this API" % resp.url
49        APIConnectionError.__init__(self, message)
50        APIError.__init__(self, resp, **kwargs)
51        self.set_retryable(value=False)
class OnboardException(builtins.Exception):
10class OnboardException(Exception):
11    """Base exception class for on-board exceptions."""
12
13    __slots__ = ()

Base exception class for on-board exceptions.

class APIConnectionError(OnboardException, builtins.ConnectionError):
16class APIConnectionError(OnboardException, ConnectionError):
17    """Exception raised when an API connection error occurs."""
18
19    __slots__ = ()

Exception raised when an API connection error occurs.

class InitialConnectionError(APIConnectionError):
22class InitialConnectionError(APIConnectionError):
23    """Exception raised only when the first try to connect to an API fails."""
24
25    __slots__ = ()
26
27    def __init__(self, message: str = "Unable to connect to the API, are you connected to the on-board Wi-Fi?", *args):
28        super(InitialConnectionError, self).__init__(message, *args)

Exception raised only when the first try to connect to an API fails.

InitialConnectionError( message: str = 'Unable to connect to the API, are you connected to the on-board Wi-Fi?', *args)
27    def __init__(self, message: str = "Unable to connect to the API, are you connected to the on-board Wi-Fi?", *args):
28        super(InitialConnectionError, self).__init__(message, *args)
class DataInvalidError(APIConnectionError):
31class DataInvalidError(APIConnectionError):
32    """Error raised when an API sends a response that could not be parsed
33    due to a formatting error or when the data is missing."""
34
35    __slots__ = ()
36
37    def __init__(self, message: str = "The API returned an invalid response", *args):
38        super(DataInvalidError, self).__init__(message, *args)

Error raised when an API sends a response that could not be parsed due to a formatting error or when the data is missing.

DataInvalidError(message: str = 'The API returned an invalid response', *args)
37    def __init__(self, message: str = "The API returned an invalid response", *args):
38        super(DataInvalidError, self).__init__(message, *args)
class APIFeatureMissingError(APIConnectionError, restfly.errors.APIError):
41class APIFeatureMissingError(APIConnectionError, APIError):
42    """Error raised when an API could support a feature,
43    but the actual implementation onboard this vehicle does not support this feature."""
44
45    __slots__ = ()
46
47    def __init__(self, resp, message: str = None, **kwargs):
48        if not message:
49            message = "The requested feature (%s) is not supported by this API" % resp.url
50        APIConnectionError.__init__(self, message)
51        APIError.__init__(self, resp, **kwargs)
52        self.set_retryable(value=False)

Error raised when an API could support a feature, but the actual implementation onboard this vehicle does not support this feature.

APIFeatureMissingError(resp, message: str = None, **kwargs)
47    def __init__(self, resp, message: str = None, **kwargs):
48        if not message:
49            message = "The requested feature (%s) is not supported by this API" % resp.url
50        APIConnectionError.__init__(self, message)
51        APIError.__init__(self, resp, **kwargs)
52        self.set_retryable(value=False)