import { type LiFiStep, type Process } from '@lifi/types'; import { ErrorMessage, LiFiErrorCode, SDKError, TransactionError, UnknownError, } from '@lifi/sdk'; export const parseMVMErrors = async ( e: Error, step?: LiFiStep, process?: Process, ): Promise => { if (e instanceof SDKError) { e.step = e.step ?? step; e.process = e.process ?? process; return e; } const baseError = await handleSpecificErrors(e, step, process); return new SDKError(baseError, step, process); }; const handleSpecificErrors = async ( e: any, step?: LiFiStep, process?: Process, ) => { if (e.message.includes('Rejected from user')) { return new TransactionError(LiFiErrorCode.SignatureRejected, e.message, e); } return new UnknownError(e.message || ErrorMessage.UnknownError, e); };