/** * Options for creating a KeyringControllerError. */ export type KeyringControllerErrorOptions = { /** * The underlying error that caused this error (for error chaining). * Uses the standard Error.cause property (ES2022). */ cause?: Error; /** * Optional error code for programmatic error handling. * This can be used to identify specific error types without string matching. */ code?: string; /** * Additional context data associated with the error. * Useful for debugging and error reporting. */ context?: Record; }; /** * Error class for KeyringController-related errors. * * This error class extends the standard Error class and supports: * - Error chaining via the `cause` property (ES2022 standard) * - Optional error codes for programmatic error handling * - Additional context data for debugging * - Backward compatibility with the legacy `originalError` property */ export declare class KeyringControllerError extends Error { /** * Optional error code for programmatic error handling. */ code?: string; /** * Additional context data associated with the error. */ context?: Record; /** * The underlying error that caused this error (ES2022 standard). * This is set manually for compatibility with older TypeScript versions. */ cause?: Error; /** * @deprecated Use `cause` instead. This property is maintained for backward compatibility. */ originalError?: Error; /** * Creates a new KeyringControllerError. * * @param message - The error message. * @param options - Error options or an Error object for backward compatibility. */ constructor(message: string, options?: KeyringControllerErrorOptions | Error); /** * Returns a JSON representation of the error. * Useful for logging and error reporting. * * @returns JSON representation of the error. */ toJSON(): Record; /** * Returns a string representation of the error chain. * Includes all chained errors for better debugging. * * @returns String representation of the error chain. */ toString(): string; } /** * Returns `true` if the error is a `KeyringControllerError`. * * Uses duck-typing on `error.name` rather than `instanceof` so that the check * remains correct when multiple major versions of `@metamask/keyring-controller` * coexist in the dependency tree (different versions produce different classes, * so `instanceof` would return `false` for errors from another version). * * @param error - The value to check. * @returns Whether the error is a `KeyringControllerError`. */ export declare function isKeyringControllerError(error: unknown): error is KeyringControllerError; /** * Returns `true` if the error is a `KeyringNotFound` error thrown by * `KeyringController:withKeyring`. Use this to distinguish a missing keyring * from other failures and apply fallback logic. * * @param error - The value to check. * @returns Whether the error is a `KeyringNotFound` error. */ export declare function isKeyringNotFoundError(error: unknown): error is KeyringControllerError; //# sourceMappingURL=errors.d.mts.map