From 4b5908d6cc045db7753b1a4d16f247b223799760 Mon Sep 17 00:00:00 2001 From: kavore <161734431+kavore@users.noreply.github.com> Date: Mon, 2 Feb 2026 23:55:04 +0300 Subject: [PATCH] fix(promo): Improve error handling for promo code application - Enhanced the logic for determining the response to users when a promo code application fails, ensuring clearer messaging based on the type of error encountered. - Introduced specific error messages for cases where the promo code is not found or not applicable as a discount, improving user experience and clarity. --- bot/handlers/user/promo_user.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bot/handlers/user/promo_user.py b/bot/handlers/user/promo_user.py index b5db0c4..cefcd2c 100644 --- a/bot/handlers/user/promo_user.py +++ b/bot/handlers/user/promo_user.py @@ -193,7 +193,16 @@ async def process_promo_code_input(message: types.Message, state: FSMContext, f"Promo code '{code_input}' application failed for user {user.id}. " f"Bonus reason: {result}. Discount reason: {result_discount}" ) - response_to_user_text = result_discount # Prefer the discount attempt error + bonus_not_found_text = _( + "promo_code_not_found", code=code_input.upper() + ) + discount_not_found_text = _( + "promo_code_not_found_or_not_discount", code=code_input.upper() + ) + if result != bonus_not_found_text and result_discount == discount_not_found_text: + response_to_user_text = result + else: + response_to_user_text = result_discount # Prefer the discount attempt error reply_markup = get_back_to_main_menu_markup( current_lang, i18n )