Skip to content

Commit

Permalink
improve(suggested-fees): Filter underlying simulation reasons (#885)
Browse files Browse the repository at this point in the history
  • Loading branch information
pxrl authored Oct 26, 2023
1 parent 1672213 commit 95e89d5
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions api/_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
};

Expand Down Expand Up @@ -729,6 +727,15 @@ export function applyMapFilter<InputType, MapType>(
}, []);
}

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
Expand Down

2 comments on commit 95e89d5

@vercel
Copy link

@vercel vercel bot commented on 95e89d5 Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

goerli-frontend-v2 – ./

goerli-frontend-v2-uma.vercel.app
goerli-frontend-v2.vercel.app
goerli-frontend-v2-git-master-uma.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 95e89d5 Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.