Skip to content

Exceptions

ApiSetupError

Bases: QuickApiException

An error setting up the BaseApi subclass.

Source code in quickapi/exceptions.py
Python
22
23
24
25
26
27
28
29
class ApiSetupError(QuickApiException):
    """An error setting up the `BaseApi` subclass."""

    def __init__(self, attribute: str):
        message = (
            f"Api setup error. Missing or invalid required attribute `{attribute}`."
        )
        super().__init__(message)

ClientSetupError

Bases: QuickApiException

An error setting up the BaseClient subclass.

Source code in quickapi/exceptions.py
Python
12
13
14
15
16
17
18
19
class ClientSetupError(QuickApiException):
    """An error setting up the `BaseClient` subclass."""

    def __init__(self, attribute: str):
        message = (
            f"Client setup error. Missing or invalid required attribute `{attribute}`."
        )
        super().__init__(message)

DictDeserializationError

Bases: QuickApiException

Dict deserialization failed.

Source code in quickapi/exceptions.py
Python
63
64
65
66
67
68
69
70
class DictDeserializationError(QuickApiException):
    """Dict deserialization failed."""

    expected_type = ""

    def __init__(self, expected_type: str):
        self.expected_type = expected_type
        super().__init__(self.__doc__)

DictSerializationError

Bases: QuickApiException

Dict serialization failed.

Source code in quickapi/exceptions.py
Python
53
54
55
56
57
58
59
60
class DictSerializationError(QuickApiException):
    """Dict serialization failed."""

    expected_type = ""

    def __init__(self, expected_type: str):
        self.expected_type = expected_type
        super().__init__(self.__doc__)

HTTPError

Bases: QuickApiException

The response received a non 200 response status code.

Source code in quickapi/exceptions.py
Python
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class HTTPError(QuickApiException):
    """The response received a non `200` response status code."""

    status_code: int
    body: "DictSerializableT | str"
    handled: bool = False

    def __init__(
        self,
        client_response: "BaseHttpClientResponse",
        status_code: int,
        body: "DictSerializableT | str",
        handled: bool = False,
    ):
        message = f"HTTP request received a non `HTTP 200 (OK)` response. The response status code was `{status_code}`."
        self.status_code = status_code
        self.body = body
        self.handled = handled
        super().__init__(message)

MissingDependencyError

Bases: QuickApiException

Trying to use an optional dependency without installing it first.

Source code in quickapi/exceptions.py
Python
91
92
93
94
95
96
97
98
99
class MissingDependencyError(QuickApiException):
    """Trying to use an optional dependency without installing it first."""

    def __init__(self, dependency: str):
        message = (
            f"Using an optional dependecy without installing it first `{dependency}`."
            f"Please install the dependency using `pip install quickapiclient[{dependency}]`."
        )
        super().__init__(message)

QuickApiException

Bases: Exception

A QuickApi exception has occurred.

Source code in quickapi/exceptions.py
Python
8
9
class QuickApiException(Exception):
    """A QuickApi exception has occurred."""

RequestSerializationError

Bases: QuickApiException

The request was not serializable to the configured type.

Source code in quickapi/exceptions.py
Python
81
82
83
84
85
86
87
88
class RequestSerializationError(QuickApiException):
    """The request was not serializable to the configured type."""

    def __init__(self, expected_type: str):
        message = (
            f"HTTP request params/body did not match expected type `{expected_type}`."
        )
        super().__init__(message)

ResponseSerializationError

Bases: QuickApiException

The response received was not serializable to the configured response_body type.

Source code in quickapi/exceptions.py
Python
73
74
75
76
77
78
class ResponseSerializationError(QuickApiException):
    """The response received was not serializable to the configured `response_body` type."""

    def __init__(self, expected_type: str):
        message = f"HTTP response body did not match expected type `{expected_type}`."
        super().__init__(message)