@metamask/snaps-sdk
Version:
A library containing the core functionality for building MetaMask Snaps
63 lines • 2.77 kB
text/typescript
/// <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 "__#7832@#code": number;
readonly "__#7832@#message": string;
readonly "__#7832@#data"?: Record<string, Json> | undefined;
readonly "__#7832@#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.mjs").SerializedSnapError;
serialize(): import("../errors.mjs").SerializedSnapError;
cause?: unknown;
};
new (data?: Record<string, Json>): {
readonly "__#7832@#code": number;
readonly "__#7832@#message": string;
readonly "__#7832@#data"?: Record<string, Json> | undefined;
readonly "__#7832@#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.mjs").SerializedSnapError;
serialize(): import("../errors.mjs").SerializedSnapError;
cause?: unknown;
};
new (message?: string | Record<string, Json>, data?: Record<string, Json>): {
readonly "__#7832@#code": number;
readonly "__#7832@#message": string;
readonly "__#7832@#data"?: Record<string, Json> | undefined;
readonly "__#7832@#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.mjs").SerializedSnapError;
serialize(): import("../errors.mjs").SerializedSnapError;
cause?: unknown;
};
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
stackTraceLimit: number;
};
//# sourceMappingURL=error-wrappers.d.mts.map