diff --git a/api/_utils.ts b/api/_utils.ts index 2d0d6948b..08d46c223 100644 --- a/api/_utils.ts +++ b/api/_utils.ts @@ -524,11 +524,9 @@ export const getRelayerFeeDetails = async ( relayerAddress, tokenPrice ); - } catch (_e: unknown) { - // Resolve and transform the error - const e = _e as Error; - // We want to mask this error as an Input error. - throw new InputError(e?.message); + } catch (err: unknown) { + const reason = resolveEthersError(err); + throw new InputError(`Relayer fill simulation failed - ${reason}`); } }; @@ -729,6 +727,15 @@ export function applyMapFilter( }, []); } +export function resolveEthersError(err: unknown): string { + // prettier-ignore + return sdk.typeguards.isEthersError(err) + ? `${err.reason}: ${err.code}` + : sdk.typeguards.isError(err) + ? err.message + : "unknown error"; +} + /** * Handles the recurring case of error handling * @param endpoint A string numeric to indicate to the logging utility where this error occurs