/** * Core error handling: `ctx.error()` as a unified primitive. * * Single error-sending method for all contexts (events, RPC, middleware). * Sends ERROR or RPC_ERROR based on context, with auto-correlation and one-shot semantics for RPC. * Infers retry hints from ERROR_CODE_META; routes all errors through router.onError() asynchronously. */ import type { LifecycleManager } from "../engine/lifecycle.js"; import { type ExtErrorCode } from "../error.js"; import type { WsKitInternalState } from "../internal.js"; import type { ConnectionData, MinimalContext } from "./base-context.js"; /** * Options for ctx.error() calls. */ export interface ErrorOptions { /** * Override inferred retryability. If omitted, inferred from ERROR_CODE_META. */ retryable?: boolean; /** * Client backoff hint (ms). null = don't retry. Defaults to ERROR_CODE_META.suggestBackoffMs. */ retryAfterMs?: number | null; /** * Original error for error chain preservation (WHATWG Error.cause). */ cause?: unknown; /** * Custom metadata (merged with server meta). Reserved keys (type, correlationId) are stripped. */ meta?: Record; } /** * Build ctx.error(): fire-and-forget (void), async enqueue. * RPC: one-shot guard shared with reply(). Event: multiple calls allowed. * All errors route through lifecycle.handleError() asynchronously (non-blocking). * @internal */ export declare function createErrorMethod(ctx: MinimalContext & { /** * Internal state: RPC state (replied flag, correlationId), meta() function. * Set by core/plugins for error handling coordination. */ __wskit?: WsKitInternalState; }, lifecycle: LifecycleManager): (code: ExtErrorCode, message?: string, details?: Record, opts?: ErrorOptions) => void; /** * Core error enhancer: attach ctx.error() to all contexts. * Runs early (priority -1000) to ensure availability before plugins. * @internal */ export declare function createCoreErrorEnhancer(lifecycle: LifecycleManager): (ctx: MinimalContext & any) => void; //# sourceMappingURL=error-handling.d.ts.map