diff --git a/packages/web/components/swap-tool/index.tsx b/packages/web/components/swap-tool/index.tsx index 7ea06ebe54..f752ca4ae0 100644 --- a/packages/web/components/swap-tool/index.tsx +++ b/packages/web/components/swap-tool/index.tsx @@ -222,9 +222,10 @@ export const SwapTool: FunctionComponent = observer( }); } }) - .catch(() => { - console.log("reject sig"); - logEvent([EventName.Swap.swapFailed, baseEvent]); + .catch((e) => { + if (e instanceof Error && e.message.includes("Failed to send")) { + logEvent([EventName.Swap.swapFailed, baseEvent]); + } }) .finally(() => { setIsSendingTx(false); diff --git a/packages/web/hooks/use-swap.tsx b/packages/web/hooks/use-swap.tsx index 3f95fdef62..0c2cbc48e8 100644 --- a/packages/web/hooks/use-swap.tsx +++ b/packages/web/hooks/use-swap.tsx @@ -269,12 +269,16 @@ export function useSwap( () => new Promise<"multiroute" | "multihop" | "exact-in">( async (resolve, reject) => { - if (!maxSlippage) return reject(new Error("No max slippage")); + if (!maxSlippage) + return reject(new Error("Max slippage is not defined.")); if (!inAmountInput.amount) - return reject(new Error("No input amount")); - if (!account) return reject(new Error("No account")); - if (!swapAssets.fromAsset) return reject(new Error("No from asset")); - if (!swapAssets.toAsset) return reject(new Error("No to asset")); + return reject(new Error("Input amount is not specified.")); + if (!account) + return reject(new Error("Account information is missing.")); + if (!swapAssets.fromAsset) + return reject(new Error("From asset is not specified.")); + if (!swapAssets.toAsset) + return reject(new Error("To asset is not specified.")); let txParams: ReturnType; try { @@ -287,7 +291,9 @@ export function useSwap( }); } catch (e) { const error = e as Error; - return reject(error); + return reject( + new Error(`Transaction preparation failed: ${error.message}`) + ); } const { routes, tokenIn, tokenOutMinAmount } = txParams;