Skip to content
// EFFECT DAYS 2026

ChatError unstable

The error every chat operation fails with.

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.

Details

  • 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. It overrides platform error names; the original code stays on cause.
  • cause is the error underneath (an HTTP error, a client library error, a SchemaError). It is unredacted and can hold URLs, ids and payload values. Schema encoding keeps it and toJSON leaves it out, so logging an error does not print it.
22 exports Since v4.1.5 Source

Constants

fileRefused

unstable
Since v4.1.5

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

Signature

declare const fileRefused: "file_refused"
Since v4.1.5

Detail for a modal returned after the deadline: the reason is NotFound and the op openModal.

Signature

declare const interactionExpired: "interaction_expired"

Errors

ChatError

unstable
Since v4.1.5

The error every chat operation fails with.

Details

  • op is the operation that failed: post, edit, history and so on.
  • cause is the reason, so a failed span's stack trace carries the whole chain: the ChatError, the reason and the error under it.
  • retry and retryAfter delegate to the reason.
  • message is built from the platform, op, reason and detail, never from the cause.

Signature

declare class ChatError extends {
readonly _tag: "ChatError";
readonly op: string;
readonly platform: string;
readonly reason: RateLimited | Unsupported | Transport | PlatformUnavailable | NoAdapter | Unauthenticated | Forbidden | NotFound | TooLarge | InvalidRequest | InvalidResponse | Unknown;
} & YieldableError<this> {
constructor(...args: [props: {
readonly _tag?: "ChatError";
readonly op: string;
readonly platform: string;
readonly reason: RateLimited | Unsupported | Transport | PlatformUnavailable | NoAdapter | Unauthenticated | Forbidden | NotFound | TooLarge | InvalidRequest | InvalidResponse | Unknown;
}, options?: MakeOptions]);
readonly "~effect/chat/ChatError": "~effect/chat/ChatError";
readonly cause: RateLimited | Unsupported | Transport | PlatformUnavailable | NoAdapter | Unauthenticated | Forbidden | NotFound | TooLarge | InvalidRequest | InvalidResponse | Unknown;
message: string;
retry: "retry" | "uncertain" | "denied";
retryAfter: Duration | undefined;
toJSON(): unknown;
}

Example Matching on a reason

import { Effect } from "effect"
import { ChatError } from "effect/chat"
const failing = Effect.fail(
new ChatError.ChatError({
platform: "slack",
op: "post",
reason: new ChatError.NotFound({ detail: "channel_not_found" })
})
)
const program = failing.pipe(
Effect.catchReason("ChatError", "NotFound", (reason) => Effect.succeed(reason.detail))
)
await Effect.runPromise(program) // => "channel_not_found"

ChatErrorReason

type unstable
Since v4.1.5

One of the twelve reasons a ChatError holds.

Signature

type ChatErrorReason = RateLimited | Unsupported | Transport | PlatformUnavailable | NoAdapter | Unauthenticated | Forbidden | NotFound | TooLarge | InvalidRequest | InvalidResponse | Unknown

Forbidden

unstable
Since v4.1.5

Reason for a ChatError: the platform refused the request: a missing scope, not in the channel, an archived thread.

Details

Retry value denied.

Signature

declare class Forbidden extends {
readonly _tag: "Forbidden";
cause?: unknown;
detail?: string;
} & YieldableError<this> {
constructor(...args: [props?: {
readonly _tag?: "Forbidden";
cause?: unknown;
detail?: string;
}, options?: MakeOptions]);
message: string;
retry: "retry" | "uncertain" | "denied";
toJSON(): unknown;
}
Since v4.1.5

Reason for an ChatError: the platform refused the request as malformed.

Details

Retry value denied.

Signature

declare class InvalidRequest extends {
readonly _tag: "InvalidRequest";
cause?: unknown;
detail?: string;
} & YieldableError<this> {
constructor(...args: [props?: {
readonly _tag?: "InvalidRequest";
cause?: unknown;
detail?: string;
}, options?: MakeOptions]);
message: string;
retry: "retry" | "uncertain" | "denied";
toJSON(): unknown;
}
Since v4.1.5

Reason for an ChatError: the platform answered with something the adapter cannot decode.

Details

Retry value denied.

Signature

declare class InvalidResponse extends {
readonly _tag: "InvalidResponse";
cause?: unknown;
detail?: string;
} & YieldableError<this> {
constructor(...args: [props?: {
readonly _tag?: "InvalidResponse";
cause?: unknown;
detail?: string;
}, options?: MakeOptions]);
message: string;
retry: "retry" | "uncertain" | "denied";
toJSON(): unknown;
}

NoAdapter

unstable
Since v4.1.5

Reason for a ChatError: no adapter is registered for the address's platform.

Details

Retry value denied.

Signature

declare class NoAdapter extends {
readonly _tag: "NoAdapter";
cause?: unknown;
detail?: string;
} & YieldableError<this> {
constructor(...args: [props?: {
readonly _tag?: "NoAdapter";
cause?: unknown;
detail?: string;
}, options?: MakeOptions]);
message: string;
retry: "retry" | "uncertain" | "denied";
toJSON(): unknown;
}

NotFound

unstable
Since v4.1.5

Reason for a ChatError: the thread, message, user or attachment is gone.

Details

Retry value denied.

Signature

declare class NotFound extends {
readonly _tag: "NotFound";
cause?: unknown;
detail?: string;
} & YieldableError<this> {
constructor(...args: [props?: {
readonly _tag?: "NotFound";
cause?: unknown;
detail?: string;
}, options?: MakeOptions]);
message: string;
retry: "retry" | "uncertain" | "denied";
toJSON(): unknown;
}
Since v4.1.5

Reason for a ChatError: the platform answered with a server error.

Details

Retry value retry for reads, uncertain for writes.

Signature

declare class PlatformUnavailable extends {
readonly _tag: "PlatformUnavailable";
cause?: unknown;
detail?: string;
readonly retry: "retry" | "uncertain" | "denied";
} & YieldableError<this> {
constructor(...args: [props: {
readonly _tag?: "PlatformUnavailable";
cause?: unknown;
detail?: string;
readonly retry: "retry" | "uncertain" | "denied";
}, options?: MakeOptions]);
message: string;
toJSON(): unknown;
}

RateLimited

unstable
Since v4.1.5

Reason for a ChatError: the platform rate limited the request.

Details

Retry value retry: nothing happened. retryAfter is the wait the platform asked for, when it gave one.

Signature

declare class RateLimited extends {
readonly _tag: "RateLimited";
cause?: unknown;
detail?: string;
readonly retryAfter?: Duration;
} & YieldableError<this> {
constructor(...args: [props?: {
readonly _tag?: "RateLimited";
cause?: unknown;
detail?: string;
readonly retryAfter?: Duration;
}, options?: MakeOptions]);
message: string;
retry: "retry" | "uncertain" | "denied";
toJSON(): unknown;
}

TooLarge

unstable
Since v4.1.5

Reason for a ChatError: the request is past a size limit: message length, file size or download's maxBytes.

Details

  • Retry value denied.
  • subject says what was too large, when the adapter can tell: text for the message text, files for the files sent with it. An adapter sets it on every refusal of post, edit and NativeStream it can attribute.
  • Usually raised before the call. A platform-side size refusal carries the platform's error name in detail, unless a file was refused: then it is file_refused. ChatMarkdown keys its fallback on that detail, not on subject.

Signature

declare class TooLarge extends {
readonly _tag: "TooLarge";
cause?: unknown;
detail?: string;
readonly subject?: "text" | "files";
} & YieldableError<this> {
constructor(...args: [props?: {
readonly _tag?: "TooLarge";
cause?: unknown;
detail?: string;
readonly subject?: "text" | "files";
}, options?: MakeOptions]);
message: string;
retry: "retry" | "uncertain" | "denied";
toJSON(): unknown;
}

Transport

unstable
Since v4.1.5

Reason for a ChatError: the request failed in transport.

Details

Retry value retry when the request never left, uncertain when it did and no answer came.

Signature

declare class Transport extends {
readonly _tag: "Transport";
cause?: unknown;
detail?: string;
readonly retry: "retry" | "uncertain" | "denied";
} & YieldableError<this> {
constructor(...args: [props: {
readonly _tag?: "Transport";
cause?: unknown;
detail?: string;
readonly retry: "retry" | "uncertain" | "denied";
}, options?: MakeOptions]);
message: string;
toJSON(): unknown;
}
Since v4.1.5

Reason for an ChatError: the platform refused the credentials: a bad or revoked token.

Details

Retry value denied.

Signature

declare class Unauthenticated extends {
readonly _tag: "Unauthenticated";
cause?: unknown;
detail?: string;
} & YieldableError<this> {
constructor(...args: [props?: {
readonly _tag?: "Unauthenticated";
cause?: unknown;
detail?: string;
}, options?: MakeOptions]);
message: string;
retry: "retry" | "uncertain" | "denied";
toJSON(): unknown;
}

Unknown

unstable
Since v4.1.5

Reason for an ChatError: the request failed for a reason the adapter cannot classify.

Details

Retry value uncertain: a write may or may not have landed.

Signature

declare class Unknown extends {
readonly _tag: "Unknown";
cause?: unknown;
detail?: string;
} & YieldableError<this> {
constructor(...args: [props?: {
readonly _tag?: "Unknown";
cause?: unknown;
detail?: string;
}, options?: MakeOptions]);
message: string;
retry: "retry" | "uncertain" | "denied";
toJSON(): unknown;
}

Unsupported

unstable
Since v4.1.5

Reason for an ChatError: the platform has no equivalent for the op.

Details

Retry value denied. Every op exists on every platform and fails with this where the platform has no equivalent; capability names what is missing.

Signature

declare class Unsupported extends {
readonly _tag: "Unsupported";
readonly capability: "getUser" | "edit" | "delete" | "fetchMessage" | "history" | "download" | "startThread" | "getThread" | "opener" | "files" | "replyTo" | "nativeStream" | "buttons" | "selects" | "modals" | "modalErrors" | "commands" | "ephemeral";
cause?: unknown;
detail?: string;
} & YieldableError<this> {
constructor(...args: [props: {
readonly _tag?: "Unsupported";
readonly capability: "getUser" | "edit" | "delete" | "fetchMessage" | "history" | "download" | "startThread" | "getThread" | "opener" | "files" | "replyTo" | "nativeStream" | "buttons" | "selects" | "modals" | "modalErrors" | "commands" | "ephemeral";
cause?: unknown;
detail?: string;
}, options?: MakeOptions]);
message: string;
retry: "retry" | "uncertain" | "denied";
toJSON(): unknown;
}

Guards

isChatError

unstable
Since v4.1.5

Returns whether a value is a ChatError.

Signature

declare function isChatError(u: unknown): u is ChatError

Models

Capability

type unstable
Since v4.1.5

A capability name from ChatAdapter.Descriptor.

Signature

type Capability = typeof Capability.Type

Retry

type unstable
Since v4.1.5

The retry value of a chat error.

Signature

type Retry = typeof Retry.Type

Schemas

Capability

unstable
Since v4.1.5

Schema for a capability name from ChatAdapter.Descriptor.

Details

  • buttons covers buttons and link buttons, selects selects on a message, and modals opening a modal from a click or a command.
  • modalErrors is field errors put back into an open modal. A platform without it answers errors some other way, so no op fails for it.
  • commands is slash commands arriving, and followUp working.
  • ephemeral is a command's answer that only the person who ran it sees. A platform with commands and without it refuses a private answer.

Signature

declare const Capability: Literals<readonly ["edit", "delete", "fetchMessage", "history", "download", "files", "replyTo", "startThread", "getThread", "opener", "getUser", "nativeStream", "buttons", "selects", "modals", "modalErrors", "commands", "ephemeral"]>
Since v4.1.5

Schema for the twelve reasons a ChatError holds.

Signature

declare const ChatErrorReason: Union<[typeof RateLimited, typeof Unsupported, typeof Transport, typeof PlatformUnavailable, typeof NoAdapter, typeof Unauthenticated, typeof Forbidden, typeof NotFound]>

Retry

unstable
Since v4.1.5

Schema for the retry value of a chat error.

Details

  • retry: nothing happened, safe to send again.
  • uncertain: the write may or may not have landed. Adapters never retry it.
  • denied: sending again gives the same answer.

Signature

declare const Retry: Literals<readonly ["retry", "uncertain", "denied"]>