From d07edd7c05bd57d9f8cf79562c8c32bf8d79ee74 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Mon, 13 Jan 2025 19:41:44 +0300 Subject: [PATCH] errors --- examples/swap/contracts/Swap.sol | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/swap/contracts/Swap.sol b/examples/swap/contracts/Swap.sol index 59174478..a1ffc571 100644 --- a/examples/swap/contracts/Swap.sol +++ b/examples/swap/contracts/Swap.sol @@ -32,7 +32,7 @@ contract Swap is error InvalidAddress(); error Unauthorized(); error ApprovalFailed(); - error TransferFailed(); + error TransferFailed(string); error InsufficientAmount(string); event TokenSwap( @@ -141,7 +141,9 @@ contract Swap is amount ); if (!success) { - revert TransferFailed(); + revert TransferFailed( + "Failed to transfer ZRC-20 tokens from the sender to the contract" + ); } (uint256 out, address gasZRC20, uint256 gasFee) = handleGasAndSwap( @@ -188,7 +190,9 @@ contract Swap is uint256 minInput = quoteMinInput(inputToken, targetToken); if (amount < minInput) { - revert InsufficientAmount("not enough tokens"); + revert InsufficientAmount( + "The input amount is less than the min amount required to cover the withdraw gas fee" + ); } if (gasZRC20 == inputToken) { @@ -256,7 +260,9 @@ contract Swap is out ); if (!success) { - revert TransferFailed(); + revert TransferFailed( + "Failed to transfer target tokens to the recipient on ZetaChain" + ); } } }