/** * @module utils/anchor-errors * @description Full SAP program error table (147 entries, codes 6000-6146) * plus decoder utilities. Mirrors `programs/synapse-agent-sap/src/errors.rs`. * * Use {@link decodeAnchorError} to extract a structured error from any * thrown RPC / simulation error. Use {@link SAP_ERRORS} for direct lookups. * * @category Utils * @since v0.13.0 */ export interface SapErrorEntry { readonly code: number; readonly name: string; readonly msg: string; } export declare const SAP_ERRORS: Readonly>; export declare const SAP_ERROR_BY_NAME: Readonly>; /** * @name DecodedAnchorError * @description Structured error extracted from a thrown RPC/simulation error. * @since v0.13.0 */ export interface DecodedAnchorError { readonly code: number; readonly name: string; readonly msg: string; readonly friendly: string; readonly logs?: readonly string[]; } /** * @name decodeAnchorError * @description Pull an Anchor / SAP error out of any caught value. * Handles: AnchorError, raw RPC SimulateError, `0x...` hex codes, * nested `error.errorCode.number`, and direct `code` numbers. * @returns Structured {@link DecodedAnchorError} or `null` if not a SAP error. * @since v0.13.0 */ export declare function decodeAnchorError(err: unknown): DecodedAnchorError | null; /** * @name SapPreflightError * @description Thrown by SDK preflights when an on-chain check is guaranteed * to fail. Carries the predicted error code/name so callers can branch * without parsing strings. * @since v0.13.0 */ export declare class SapPreflightError extends Error { readonly predictedCode: number; readonly predictedName: string; readonly hint?: string | undefined; readonly preflight: true; constructor(message: string, predictedCode: number, predictedName: string, hint?: string | undefined); } /** * @name throwPredicted * @description Helper for SDK preflights. Throws a {@link SapPreflightError} * carrying the on-chain error name + friendly message. * @since v0.13.0 */ export declare function throwPredicted(name: keyof typeof SAP_ERROR_BY_NAME, hint?: string): never; //# sourceMappingURL=anchor-errors.d.ts.map