GitHub

chat_error

API reference for chat_error.

The error every chat operation fails with (Effect's effect/chat/ChatError).

A ChatError records the platform and op and holds one of twelve reasons. Each reason has a three-way retry value: "retry" means nothing happened and the request is safe to send again, "uncertain" means a write may or may not have landed, and "denied" means sending again gives the same answer.

  • detail is redacted: a platform code such as channel_not_found, never message text, file names or ids. file_refused is fixed by the core: on a "denied" reason it promises a file was refused and nothing is left posted.
  • cause is the error underneath (an HTTP error, a SchemaError). It is unredacted, so message, str() and to_json() leave it out; the schema keeps it.

Handle one reason with catch_reason(ChatError, NotFound, handler).

Values

AttributeTypeDescription
RETRYLiteralsSchema[Literal['retry', 'uncertain', 'denied']]
CAPABILITIEStuple[Capability, ...]

Every capability, in Effect's order (Effect's Capability.literals).

CAPABILITYLiteralsSchema[Literal['edit', 'delete', 'fetchMessage', 'history', 'download', 'files', 'replyTo', 'startThread', 'getThread', 'opener', 'getUser', 'nativeStream', 'buttons', 'selects', 'modals', 'modalErrors', 'commands', 'ephemeral']]
FILE_REFUSEDLiteral['file_refused'] = 'file_refused'

Detail for a refused file on any "denied" reason: nothing is left posted.

INTERACTION_EXPIREDLiteral['interaction_expired'] = 'interaction_expired'

Detail for a modal or follow-up past its deadline: the reason is NotFound.

REASONStuple[type[ChatErrorReason], ...]
CHAT_ERROR_REASONS.Bottom[AnyReason]

The schema of the twelve reasons (Effect's ChatErrorReason schema).

Types

TypeDefinitionDescription
Retrytype Retry = Literal['retry', 'uncertain', 'denied']

The retry value of a chat error.

Capabilitytype Capability = Literal['edit', 'delete', 'fetchMessage', 'history', 'download', 'files', 'replyTo', 'startThread', 'getThread', 'opener', 'getUser', 'nativeStream', 'buttons', 'selects', 'modals', 'modalErrors', 'commands', 'ephemeral']

A capability name from ChatAdapter.Descriptor. buttons covers buttons and link buttons, modalErrors field errors put back into an open modal, commands slash commands and follow_up, ephemeral a command's private answer.

AnyReasontype AnyReason = RateLimited | Unsupported | Transport | PlatformUnavailable | NoAdapter | Unauthenticated | Forbidden | NotFound | TooLarge | InvalidRequest | InvalidResponse | Unknown

One of the twelve reasons a ChatError holds.

Classes

Functions

is_chat_error

is_chat_error(u) -> bool
ParameterTypeDescription
uobject

Returns bool

def is_chat_error(u: object) -> bool:
    return isinstance(u, ChatError)