Skip to content

Commit

Permalink
Display proper swap error
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman authored and futurepaul committed Jul 1, 2024
1 parent 175bdf9 commit 09a68b2
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/routes/SwapLightning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export function SwapLightning() {
return feeSats() !== 0n;
});

const [feeEstimateWarning, setFeeEstimateWarning] = createSignal<string>();
const [feeEstimateWarning, setFeeEstimateWarning] = createSignal<Error>();

const feeEstimate = async () => {
try {
Expand All @@ -146,7 +146,14 @@ export function SwapLightning() {
setStage("preview");
} catch (e) {
console.error(e);
setFeeEstimateWarning(i18n.t("swap_lightning.too_small"));
const err = eify(e);
if (err.message === "Satoshi amount is invalid") {
setFeeEstimateWarning(
new Error(i18n.t("swap_lightning.too_small"))
);
} else {
setFeeEstimateWarning(err);
}
} finally {
setLoading(false);
}
Expand Down Expand Up @@ -256,7 +263,7 @@ export function SwapLightning() {
<Suspense>
<Show when={feeEstimateWarning()}>
<InfoBox accent={"red"}>
{feeEstimateWarning()}
{feeEstimateWarning()?.message}
</InfoBox>
</Show>
</Suspense>
Expand Down

0 comments on commit 09a68b2

Please sign in to comment.