UNPKG

@metamask/snaps-sdk

Version:

A library containing the core functionality for building MetaMask Snaps

63 lines 2.78 kB
/// <reference types="node" /> import type { rpcErrors } from "@metamask/rpc-errors"; import type { Json } from "@metamask/utils"; export type JsonRpcErrorFunction = typeof rpcErrors.parse; /** * Create a `SnapError` class from an error function from * `@metamask/rpc-errors`. This is useful for creating custom error classes * which can be thrown by a Snap. * * The created class will inherit the message, code, and data properties from * the error function. * * @param fn - The error function to create the class from. * @returns The created `SnapError` class. */ export declare function createSnapError(fn: JsonRpcErrorFunction): { new (message?: string): { readonly "__#15661@#code": number; readonly "__#15661@#message": string; readonly "__#15661@#data"?: Record<string, Json> | undefined; readonly "__#15661@#stack"?: string | undefined; readonly name: string; readonly code: number; readonly message: string; readonly data: Record<string, Json> | undefined; readonly stack: string | undefined; toJSON(): import("../errors.cjs").SerializedSnapError; serialize(): import("../errors.cjs").SerializedSnapError; cause?: unknown; }; new (data?: Record<string, Json>): { readonly "__#15661@#code": number; readonly "__#15661@#message": string; readonly "__#15661@#data"?: Record<string, Json> | undefined; readonly "__#15661@#stack"?: string | undefined; readonly name: string; readonly code: number; readonly message: string; readonly data: Record<string, Json> | undefined; readonly stack: string | undefined; toJSON(): import("../errors.cjs").SerializedSnapError; serialize(): import("../errors.cjs").SerializedSnapError; cause?: unknown; }; new (message?: string | Record<string, Json>, data?: Record<string, Json>): { readonly "__#15661@#code": number; readonly "__#15661@#message": string; readonly "__#15661@#data"?: Record<string, Json> | undefined; readonly "__#15661@#stack"?: string | undefined; readonly name: string; readonly code: number; readonly message: string; readonly data: Record<string, Json> | undefined; readonly stack: string | undefined; toJSON(): import("../errors.cjs").SerializedSnapError; serialize(): import("../errors.cjs").SerializedSnapError; cause?: unknown; }; captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void; prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined; stackTraceLimit: number; }; //# sourceMappingURL=error-wrappers.d.cts.map