Skip to content

errors

StreamError

Bases: BaseStreamError

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

Source code in chatkit/errors.py
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
        self.status_code = DEFAULT_STATUS.get(code, 500)
        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
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.