@bsv/wallet-toolbox-client
Version:
Client only Wallet Storage
63 lines • 2.55 kB
TypeScript
import { ErrorCodeString10To40Bytes, ErrorDescriptionString20To200Bytes, WalletErrorObject } from '@bsv/sdk';
/**
* Derived class constructors should use the derived class name as the value for `name`,
* and an internationalizable constant string for `message`.
*
* If a derived class intends to wrap another WalletError, the public property should
* be named `walletError` and will be recovered by `fromUnknown`.
*
* Optionaly, the derived class `message` can include template parameters passed in
* to the constructor. See WERR_MISSING_PARAMETER for an example.
*
* To avoid derived class name colisions, packages should include a package specific
* identifier after the 'WERR_' prefix. e.g. 'WERR_FOO_' as the prefix for Foo package error
* classes.
*/
export declare class WalletError extends Error implements WalletErrorObject {
details?: Record<string, string> | undefined;
isError: true;
constructor(name: string, message: string, stack?: string, details?: Record<string, string> | undefined);
/**
* Error class compatible accessor for `code`.
*/
get code(): ErrorCodeString10To40Bytes;
set code(v: ErrorCodeString10To40Bytes);
/**
* Error class compatible accessor for `description`.
*/
get description(): ErrorDescriptionString20To200Bytes;
set description(v: ErrorDescriptionString20To200Bytes);
/**
* Recovers all public fields from WalletError derived error classes and relevant Error derived errors.
*
*/
static fromUnknown(err: unknown): WalletError;
/**
* @returns standard HTTP error status object with status property set to 'error'.
*/
asStatus(): {
status: string;
code: string;
description: string;
};
/**
* Base class default JSON serialization.
* Captures just the name and message properties.
*
* Override this method to safely (avoid deep, large, circular issues) serialize
* derived class properties.
*
* @returns stringified JSON representation of the WalletError.
*/
protected toJson(): string;
/**
* Safely serializes a WalletError derived, WERR_REVIEW_ACTIONS (special case), Error or unknown error to JSON.
*
* Safely means avoiding deep, large, circular issues.
*
* @param error
* @returns stringified JSON representation of the error such that it can be desirialized to a WalletError.
*/
static unknownToJson(error: unknown | WalletError): string;
}
//# sourceMappingURL=WalletError.d.ts.map