/** * 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. * * @stability unstable * @since 4.1.5 */ import type * as Duration from "../Duration.ts"; import * as Schema from "../Schema.ts"; /** * 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. * * @stability unstable * @category schemas * @since 4.1.5 */ export declare const Retry: Schema.Literals; /** * The retry value of a chat error. * * @stability unstable * @category models * @since 4.1.5 */ export type Retry = typeof Retry.Type; /** * 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. * * @stability unstable * @category schemas * @since 4.1.5 */ export declare const Capability: Schema.Literals; /** * A capability name from `ChatAdapter.Descriptor`. * * @stability unstable * @category models * @since 4.1.5 */ export type Capability = typeof Capability.Type; /** * Detail for a refused file on any `denied` reason: nothing is left posted. * * @stability unstable * @category constants * @since 4.1.5 */ export declare const fileRefused = "file_refused"; /** * Detail for a modal returned after the deadline: the reason is `NotFound` * and the op `openModal`. * * @stability unstable * @category constants * @since 4.1.5 */ export declare const interactionExpired = "interaction_expired"; declare const RateLimited_base: Schema.Class; readonly detail: Schema.optionalKey; readonly cause: Schema.optional; }>, import("../Cause.ts").YieldableError>; /** * 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. * * @stability unstable * @category errors * @since 4.1.5 */ export declare class RateLimited extends RateLimited_base { /** * The retry value of this reason, fixed per reason. * * @since 4.1.5 */ get retry(): Retry; get message(): string; toJSON(): unknown; } declare const Unsupported_base: Schema.Class; readonly detail: Schema.optionalKey; readonly cause: Schema.optional; }>, import("../Cause.ts").YieldableError>; /** * 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. * * @stability unstable * @category errors * @since 4.1.5 */ export declare class Unsupported extends Unsupported_base { /** * The retry value of this reason, fixed per reason. * * @since 4.1.5 */ get retry(): Retry; get message(): string; toJSON(): unknown; } declare const Transport_base: Schema.Class; readonly detail: Schema.optionalKey; readonly cause: Schema.optional; }>, import("../Cause.ts").YieldableError>; /** * 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. * * @stability unstable * @category errors * @since 4.1.5 */ export declare class Transport extends Transport_base { get message(): string; toJSON(): unknown; } declare const PlatformUnavailable_base: Schema.Class; readonly detail: Schema.optionalKey; readonly cause: Schema.optional; }>, import("../Cause.ts").YieldableError>; /** * Reason for a `ChatError`: the platform answered with a server error. * * **Details** * * Retry value `retry` for reads, `uncertain` for writes. * * @stability unstable * @category errors * @since 4.1.5 */ export declare class PlatformUnavailable extends PlatformUnavailable_base { get message(): string; toJSON(): unknown; } declare const NoAdapter_base: Schema.Class; readonly cause: Schema.optional; }>, import("../Cause.ts").YieldableError>; /** * Reason for a `ChatError`: no adapter is registered for the address's platform. * * **Details** * * Retry value `denied`. * * @stability unstable * @category errors * @since 4.1.5 */ export declare class NoAdapter extends NoAdapter_base { /** * The retry value of this reason, fixed per reason. * * @since 4.1.5 */ get retry(): Retry; get message(): string; toJSON(): unknown; } declare const Unauthenticated_base: Schema.Class; readonly cause: Schema.optional; }>, import("../Cause.ts").YieldableError>; /** * Reason for an `ChatError`: the platform refused the credentials: a bad or revoked token. * * **Details** * * Retry value `denied`. * * @stability unstable * @category errors * @since 4.1.5 */ export declare class Unauthenticated extends Unauthenticated_base { /** * The retry value of this reason, fixed per reason. * * @since 4.1.5 */ get retry(): Retry; get message(): string; toJSON(): unknown; } declare const Forbidden_base: Schema.Class; readonly cause: Schema.optional; }>, import("../Cause.ts").YieldableError>; /** * Reason for a `ChatError`: the platform refused the request: a missing scope, not in the channel, an archived thread. * * **Details** * * Retry value `denied`. * * @stability unstable * @category errors * @since 4.1.5 */ export declare class Forbidden extends Forbidden_base { /** * The retry value of this reason, fixed per reason. * * @since 4.1.5 */ get retry(): Retry; get message(): string; toJSON(): unknown; } declare const NotFound_base: Schema.Class; readonly cause: Schema.optional; }>, import("../Cause.ts").YieldableError>; /** * Reason for a `ChatError`: the thread, message, user or attachment is gone. * * **Details** * * Retry value `denied`. * * @stability unstable * @category errors * @since 4.1.5 */ export declare class NotFound extends NotFound_base { /** * The retry value of this reason, fixed per reason. * * @since 4.1.5 */ get retry(): Retry; get message(): string; toJSON(): unknown; } declare const TooLarge_base: Schema.Class>; readonly detail: Schema.optionalKey; readonly cause: Schema.optional; }>, import("../Cause.ts").YieldableError>; /** * 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`. * * @stability unstable * @category errors * @since 4.1.5 */ export declare class TooLarge extends TooLarge_base { /** * The retry value of this reason, fixed per reason. * * @since 4.1.5 */ get retry(): Retry; get message(): string; toJSON(): unknown; } declare const InvalidRequest_base: Schema.Class; readonly cause: Schema.optional; }>, import("../Cause.ts").YieldableError>; /** * Reason for an `ChatError`: the platform refused the request as malformed. * * **Details** * * Retry value `denied`. * * @stability unstable * @category errors * @since 4.1.5 */ export declare class InvalidRequest extends InvalidRequest_base { /** * The retry value of this reason, fixed per reason. * * @since 4.1.5 */ get retry(): Retry; get message(): string; toJSON(): unknown; } declare const InvalidResponse_base: Schema.Class; readonly cause: Schema.optional; }>, import("../Cause.ts").YieldableError>; /** * Reason for an `ChatError`: the platform answered with something the adapter cannot decode. * * **Details** * * Retry value `denied`. * * @stability unstable * @category errors * @since 4.1.5 */ export declare class InvalidResponse extends InvalidResponse_base { /** * The retry value of this reason, fixed per reason. * * @since 4.1.5 */ get retry(): Retry; get message(): string; toJSON(): unknown; } declare const Unknown_base: Schema.Class; readonly cause: Schema.optional; }>, import("../Cause.ts").YieldableError>; /** * 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. * * @stability unstable * @category errors * @since 4.1.5 */ export declare class Unknown extends Unknown_base { /** * The retry value of this reason, fixed per reason. * * @since 4.1.5 */ get retry(): Retry; get message(): string; toJSON(): unknown; } /** * One of the twelve reasons a `ChatError` holds. * * @stability unstable * @category errors * @since 4.1.5 */ export type ChatErrorReason = RateLimited | Unsupported | Transport | PlatformUnavailable | NoAdapter | Unauthenticated | Forbidden | NotFound | TooLarge | InvalidRequest | InvalidResponse | Unknown; /** * Schema for the twelve reasons a `ChatError` holds. * * @stability unstable * @category schemas * @since 4.1.5 */ export declare const ChatErrorReason: Schema.Union<[ typeof RateLimited, typeof Unsupported, typeof Transport, typeof PlatformUnavailable, typeof NoAdapter, typeof Unauthenticated, typeof Forbidden, typeof NotFound, typeof TooLarge, typeof InvalidRequest, typeof InvalidResponse, typeof Unknown ]>; declare const TypeId: "~effect/chat/ChatError"; declare const ChatError_base: Schema.Class; }>, import("../Cause.ts").YieldableError>; /** * 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. * * **Example** (Matching on a reason) * * ```ts import.meta.vitest * 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" * ``` * * @stability unstable * @category errors * @since 4.1.5 */ export declare class ChatError extends ChatError_base { /** * Marks the value as a `ChatError` for `isChatError`. * * @since 4.1.5 */ readonly [TypeId]: "~effect/chat/ChatError"; /** * The reason, so the chain under it ends up in a failed span's stack trace. * * @since 4.1.5 */ readonly cause: Forbidden | InvalidRequest | InvalidResponse | NoAdapter | NotFound | PlatformUnavailable | RateLimited | TooLarge | Transport | Unauthenticated | Unknown | Unsupported; /** * The retry value of the reason. * * @since 4.1.5 */ get retry(): Retry; /** * The wait the platform asked for before a retry, when the reason is * `RateLimited` and it gave one. * * @since 4.1.5 */ get retryAfter(): Duration.Duration | undefined; get message(): string; toJSON(): unknown; } /** * Returns whether a value is a `ChatError`. * * @stability unstable * @category guards * @since 4.1.5 */ export declare const isChatError: (u: unknown) => u is ChatError; export {}; //# sourceMappingURL=ChatError.d.ts.map