Skip to content

exceptions

Library exceptions.

APIError

Bases: ImouException

Remote API error.

Source code in imouapi/exceptions.py
60
61
62
63
64
65
class APIError(ImouException):
    """Remote API error."""

    def get_title(self) -> str:
        """Return the title of the exception which will be then translated."""
        return "api_error"

get_title()

Return the title of the exception which will be then translated.

Source code in imouapi/exceptions.py
63
64
65
def get_title(self) -> str:
    """Return the title of the exception which will be then translated."""
    return "api_error"

ConnectionFailed

Bases: ImouException

Failed to connect to the API.

Source code in imouapi/exceptions.py
36
37
38
39
40
41
class ConnectionFailed(ImouException):
    """Failed to connect to the API."""

    def get_title(self) -> str:
        """Return the title of the exception which will be then translated."""
        return "connection_failed"

get_title()

Return the title of the exception which will be then translated.

Source code in imouapi/exceptions.py
39
40
41
def get_title(self) -> str:
    """Return the title of the exception which will be then translated."""
    return "connection_failed"

DeviceOffline

Bases: ImouException

Device is offline.

Source code in imouapi/exceptions.py
76
77
78
79
80
81
class DeviceOffline(ImouException):
    """Device is offline."""

    def get_title(self) -> str:
        """Return the title of the exception which will be then translated."""
        return "device_offline"

get_title()

Return the title of the exception which will be then translated.

Source code in imouapi/exceptions.py
79
80
81
def get_title(self) -> str:
    """Return the title of the exception which will be then translated."""
    return "device_offline"

ImouException

Bases: Exception

Base exception.

Source code in imouapi/exceptions.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class ImouException(Exception):
    """Base exception."""

    def __init__(self, message: str = "") -> None:
        """Initialize."""
        self.message = message
        super().__init__(self.message)

    def to_string(self) -> str:
        """Return the exception as a string."""
        return f"{self.__class__.__name__}: {self.message}\n" + self.traceback()

    def traceback(self) -> str:
        """Return the traceback as a string."""
        etype, value, trace = sys.exc_info()
        return "".join(traceback.format_exception(etype, value, trace, None))

    def get_title(self) -> str:
        """Return the title of the exception which will be then translated."""
        return "generic_error"

__init__(message='')

Initialize.

Source code in imouapi/exceptions.py
 9
10
11
12
def __init__(self, message: str = "") -> None:
    """Initialize."""
    self.message = message
    super().__init__(self.message)

get_title()

Return the title of the exception which will be then translated.

Source code in imouapi/exceptions.py
23
24
25
def get_title(self) -> str:
    """Return the title of the exception which will be then translated."""
    return "generic_error"

to_string()

Return the exception as a string.

Source code in imouapi/exceptions.py
14
15
16
def to_string(self) -> str:
    """Return the exception as a string."""
    return f"{self.__class__.__name__}: {self.message}\n" + self.traceback()

traceback()

Return the traceback as a string.

Source code in imouapi/exceptions.py
18
19
20
21
def traceback(self) -> str:
    """Return the traceback as a string."""
    etype, value, trace = sys.exc_info()
    return "".join(traceback.format_exception(etype, value, trace, None))

InvalidConfiguration

Bases: ImouException

Invalid App Id or App Secret provided.

Source code in imouapi/exceptions.py
44
45
46
47
48
49
class InvalidConfiguration(ImouException):
    """Invalid App Id or App Secret provided."""

    def get_title(self) -> str:
        """Return the title of the exception which will be then translated."""
        return "invalid_configuration"

get_title()

Return the title of the exception which will be then translated.

Source code in imouapi/exceptions.py
47
48
49
def get_title(self) -> str:
    """Return the title of the exception which will be then translated."""
    return "invalid_configuration"

InvalidResponse

Bases: ImouException

Malformed or unexpected API response.

Source code in imouapi/exceptions.py
68
69
70
71
72
73
class InvalidResponse(ImouException):
    """Malformed or unexpected API response."""

    def get_title(self) -> str:
        """Return the title of the exception which will be then translated."""
        return "invalid_reponse"

get_title()

Return the title of the exception which will be then translated.

Source code in imouapi/exceptions.py
71
72
73
def get_title(self) -> str:
    """Return the title of the exception which will be then translated."""
    return "invalid_reponse"

NotAuthorized

Bases: ImouException

Not authorized to operate on the device or invalid device id.

Source code in imouapi/exceptions.py
52
53
54
55
56
57
class NotAuthorized(ImouException):
    """Not authorized to operate on the device or invalid device id."""

    def get_title(self) -> str:
        """Return the title of the exception which will be then translated."""
        return "not_authorized"

get_title()

Return the title of the exception which will be then translated.

Source code in imouapi/exceptions.py
55
56
57
def get_title(self) -> str:
    """Return the title of the exception which will be then translated."""
    return "not_authorized"

NotConnected

Bases: ImouException

Action requested but not yet connected to the API.

Source code in imouapi/exceptions.py
28
29
30
31
32
33
class NotConnected(ImouException):
    """Action requested but not yet connected to the API."""

    def get_title(self) -> str:
        """Return the title of the exception which will be then translated."""
        return "not_connected"

get_title()

Return the title of the exception which will be then translated.

Source code in imouapi/exceptions.py
31
32
33
def get_title(self) -> str:
    """Return the title of the exception which will be then translated."""
    return "not_connected"