@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
46 lines • 1.45 kB
TypeScript
/**
* Error Parser
* Routes errors to appropriate error classes based on step and context
*/
/**
* Transaction step where error occurred
*/
export declare enum StepError {
NONCE = "NonceStepError",
PAYLOAD = "PayloadStepError",
SIGNATURE = "SignatureStepError",
IGNORED_SIGNATURE = "IgnoredSignatureStepError",
CHECK_FUNDS = "CheckFundsStepError",
LIST_ACCOUNT = "ListAccountStepError",
LIST_CURRENCY = "ListCurrencyStepError",
UNKNOWN_ACCOUNT = "UnknownAccountStepError",
PAYIN_EXTRA_ID = "PayinExtraIdStepError"
}
/**
* Input for error parsing
*/
export declare enum CustomErrorType {
SWAP = "swap"
}
export type ParseError = {
error: Error;
step?: StepError;
customErrorType?: CustomErrorType;
};
/**
* Creates a step-specific error by wrapping the original error
*
* @param error - Original error that occurred
* @param step - Step where error occurred (optional)
* @returns Wrapped error or original error if no step specified
*/
export declare function createStepError({ error, step }: ParseError): Error;
/**
* Parses an error to determine the correct error class to return based on the context.
*/
export declare function parseError({ error, step, customErrorType }: ParseError): Error;
export declare const hasMessage: (value: unknown) => value is {
message?: unknown;
};
export declare const toError: (value: unknown) => Error;
//# sourceMappingURL=parser.d.ts.map