From e4fa4c6595df7b371d3c87b8cbf63dddc2bb2e84 Mon Sep 17 00:00:00 2001 From: cryptooda Date: Fri, 10 Oct 2025 22:40:44 +0700 Subject: [PATCH] Add High network fees error message --- .../Handlers/OpenPositionCommandHandler.cs | 4 ++-- src/Managing.Core/Exceptions/CustomExceptions.cs | 16 +++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Managing.Application/Trading/Handlers/OpenPositionCommandHandler.cs b/src/Managing.Application/Trading/Handlers/OpenPositionCommandHandler.cs index 8d9d750a..bd1fd847 100644 --- a/src/Managing.Application/Trading/Handlers/OpenPositionCommandHandler.cs +++ b/src/Managing.Application/Trading/Handlers/OpenPositionCommandHandler.cs @@ -53,8 +53,8 @@ namespace Managing.Application.Trading.Handlers if (currentGasFees > Constants.GMX.Config.MaximumGasFeeUsd) { throw new InsufficientFundsException( - $"Gas fee too high for position opening: {currentGasFees:F2} USD (threshold: {Constants.GMX.Config.MaximumGasFeeUsd} USD). Position opening cancelled.", - InsufficientFundsType.InsufficientEth); + $"Gas fee too high for position opening: {currentGasFees:F2} USD (threshold: {Constants.GMX.Config.MaximumGasFeeUsd} USD). Position opening rejected.", + InsufficientFundsType.HighNetworkFee); } } } diff --git a/src/Managing.Core/Exceptions/CustomExceptions.cs b/src/Managing.Core/Exceptions/CustomExceptions.cs index 145677ad..9062041f 100644 --- a/src/Managing.Core/Exceptions/CustomExceptions.cs +++ b/src/Managing.Core/Exceptions/CustomExceptions.cs @@ -105,21 +105,26 @@ public class InsufficientFundsException : Exception return errorType switch { InsufficientFundsType.InsufficientEth => - "❌ **Insufficient ETH for Gas Fees**\n" + + "❌ Insufficient ETH for Gas Fees\n" + "Your wallet doesn't have enough ETH to pay for transaction gas fees.\n" + "Please add ETH to your wallet and try again.", InsufficientFundsType.InsufficientAllowance => - "❌ **Insufficient Token Allowance**\n" + + "❌ Insufficient Token Allowance\n" + "The trading contract doesn't have permission to spend your tokens.\n" + "Please approve token spending in your wallet and try again.", InsufficientFundsType.InsufficientBalance => - "❌ **Insufficient Token Balance**\n" + + "❌ Insufficient Token Balance\n" + "Your wallet doesn't have enough tokens for this trade.\n" + "Please add more tokens to your wallet and try again.", + + InsufficientFundsType.HighNetworkFee => + "❌ High Network Fee\n" + + "The gas fee for this position is too high.\n" + + "Position opening rejected.", - _ => "❌ **Transaction Failed**\n" + + _ => "❌ Transaction Failed\n" + "The transaction failed due to insufficient funds.\n" + "Please check your wallet balance and try again." }; @@ -149,5 +154,6 @@ public enum InsufficientFundsType /// /// General insufficient funds error /// - General + General, + HighNetworkFee } \ No newline at end of file