Skip to content

errors

InvalidRequestError

Bases: ValueError

The request body could not be parsed as a ChatKit operation.

Source code in chatkit/errors.py
 7
 8
 9
10
11
12
class InvalidRequestError(ValueError):
    """The request body could not be parsed as a ChatKit operation."""

    def __init__(self, validation_error: ValidationError):
        super().__init__("Invalid ChatKit request body")
        self.validation_error = validation_error

InvalidOperationError

Bases: ValueError

The validated request cannot be applied to the target resource.

Source code in chatkit/errors.py
15
16
class InvalidOperationError(ValueError):
    """The validated request cannot be applied to the target resource."""

UnsupportedOperationError

Bases: RuntimeError

The requested capability has not been configured on the server.

Source code in chatkit/errors.py
19
20
class UnsupportedOperationError(RuntimeError):
    """The requested capability has not been configured on the server."""

StreamError

Bases: BaseStreamError

Error with a specific error code that maps to a localized user-facing error message.

Source code in chatkit/errors.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
class StreamError(BaseStreamError):
    """
    Error with a specific error code that maps to a localized user-facing
    error message.
    """

    code: ErrorCode

    def __init__(
        self,
        code: ErrorCode,
        *,
        allow_retry: bool | None = None,
    ):
        self.code = code
        if allow_retry is None:
            self.allow_retry = DEFAULT_ALLOW_RETRY.get(code, False)
        else:
            self.allow_retry = allow_retry

CustomStreamError

Bases: BaseStreamError

Error with a custom user-facing error message. The message should be localized as needed before raising the error.

Source code in chatkit/errors.py
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
class CustomStreamError(BaseStreamError):
    """
    Error with a custom user-facing error message. The message should be
    localized as needed before raising the error.
    """

    message: str
    """The user-facing error message to display."""

    def __init__(
        self,
        message: str,
        *,
        allow_retry: bool = False,
    ):
        self.message = message
        self.allow_retry = allow_retry

message instance-attribute

message: str = message

The user-facing error message to display.