import { Next } from 'hono'; import { ContentfulStatusCode } from 'hono/utils/http-status'; declare const INTERNAL_ERROR_CODE = "internal_error"; declare const INTERNAL_ERROR_DESCRIPTION = "An internal error occurred"; type InternalErrorMetadata = Record; declare const USER_ERROR_CODE = "user_error"; declare const BRIDGE_RIVET_ERROR_PREFIX = "__RIVET_ERROR_JSON__:"; interface RivetErrorOptions extends ErrorOptions { /** Error data can safely be serialized in a response to the client. */ public?: boolean; /** Metadata associated with this error. */ metadata?: unknown; /** Request identifier used to correlate this error with engine logs. */ rayId?: string; /** Explicit HTTP status override for router responses. */ statusCode?: number; /** Actor context associated with this error. */ actor?: ActorSpecifier; } /** Identifies the actor that was handling work when an error was produced. */ interface ActorSpecifier { actorId: string; generation: number; key?: string; } interface RivetErrorLike { __type?: "ActorError" | "RivetError"; group: string; code: string; message: string; metadata?: unknown; rayId?: string; public?: boolean; statusCode?: number; actor?: ActorSpecifier; } interface BridgeRivetErrorPayload extends RivetErrorLike { } interface UserErrorOptions extends ErrorOptions { /** * Machine readable code for this error. Useful for catching different types of * errors in try-catch. */ code?: string; /** * Additional metadata related to the error. Useful for understanding context * about the error. */ metadata?: unknown; } declare function isRivetErrorLike(error: unknown): error is RivetError | DeconstructedError | RivetErrorLike; declare function isActorAbortedError(error: unknown): boolean; declare class RivetError extends Error { __type: "RivetError"; public: boolean; metadata?: unknown; readonly rayId?: string; statusCode: number; actor?: ActorSpecifier; readonly group: string; readonly code: string; static isRivetError(error: unknown): error is RivetError | DeconstructedError; static isActorError(error: unknown): error is RivetError | DeconstructedError; constructor(group: string, code: string, message: string, options?: RivetErrorOptions | unknown); toString(): string; } declare class UserError extends RivetError { constructor(message: string, options?: UserErrorOptions); } declare function toRivetError(error: unknown, fallback?: Partial): RivetError; /** A structured error encoded for the bridge to Core. */ interface EncodedBridgeError { readonly encoded: string; /** Set when JSON could not encode the metadata, which was dropped. */ readonly droppedMetadataCause?: unknown; } /** * Encodes a structured error for the bridge to Core. Metadata that JSON cannot * encode, such as a `bigint`, is dropped so the error itself still crosses. */ declare function encodeBridgeRivetError(error: RivetErrorLike): EncodedBridgeError; /** * Encodes an error for the telemetry bridge. A structured error crosses with * its group and code. Anything else crosses as text so Core classifies it, * which is the same rule that keeps raw messages out of every span. */ declare function encodeErrorForBridge(error: unknown): string; /** A `RivetError` instance, or a plain object carrying its full tagged shape. */ declare function isCanonicalStructuredRivetError(error: unknown): error is RivetErrorLike; declare function decodeBridgeRivetErrorPayload(value: string): BridgeRivetErrorPayload | undefined; declare function decodeBridgeRivetError(value: string): RivetError | undefined; declare function isRivetErrorCode(error: unknown, group: string, code: string): error is RivetError; declare function internalError(message: string, options?: Partial & { group?: string; code?: string; }): RivetError; declare function invalidEncoding(format?: string): RivetError; declare function invalidRequest(error?: unknown): RivetError; declare function actorNotFound(identifier?: string): RivetError; declare function actorStopping(identifier?: string): RivetError; interface ActorRestartingOptions { phase?: "stopping" | "sleeping" | "waking" | "runner_shutdown"; retryAfterMs?: number; } declare function actorRestarting(opts?: ActorRestartingOptions): RivetError; declare function forbiddenError(): RivetError; declare function unsupportedFeature(feature: string): RivetError; declare function assertUnreachable(x: never): never; interface DeconstructedError { __type: "ActorError"; statusCode: ContentfulStatusCode; public: boolean; group: string; code: string; message: string; metadata?: unknown; rayId?: string; actor?: ActorSpecifier; } declare function stringifyError(error: unknown): string; /** Generates a `Next` handler to pass to middleware in order to be able to call arbitrary middleware. */ declare function noopNext(): Next; export { type ActorRestartingOptions as A, BRIDGE_RIVET_ERROR_PREFIX as B, toRivetError as C, unsupportedFeature as D, type EncodedBridgeError as E, INTERNAL_ERROR_CODE as I, RivetError as R, UserError as U, type RivetErrorLike as a, type RivetErrorOptions as b, type UserErrorOptions as c, assertUnreachable as d, type ActorSpecifier as e, type BridgeRivetErrorPayload as f, INTERNAL_ERROR_DESCRIPTION as g, type InternalErrorMetadata as h, USER_ERROR_CODE as i, actorNotFound as j, actorRestarting as k, actorStopping as l, decodeBridgeRivetError as m, noopNext as n, decodeBridgeRivetErrorPayload as o, encodeBridgeRivetError as p, encodeErrorForBridge as q, forbiddenError as r, stringifyError as s, internalError as t, invalidEncoding as u, invalidRequest as v, isActorAbortedError as w, isCanonicalStructuredRivetError as x, isRivetErrorCode as y, isRivetErrorLike as z };