From 123547b62c22255ba1cb77761c08296194272cc1 Mon Sep 17 00:00:00 2001 From: jsdio Date: Sat, 14 Oct 2023 02:09:04 +0300 Subject: [PATCH] feat: [#49] Improved error display --- src/bot_aiogram/tgbot/handlers/voice.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bot_aiogram/tgbot/handlers/voice.py b/src/bot_aiogram/tgbot/handlers/voice.py index 1645010..f6c5742 100644 --- a/src/bot_aiogram/tgbot/handlers/voice.py +++ b/src/bot_aiogram/tgbot/handlers/voice.py @@ -1,3 +1,4 @@ +import json import io import typing @@ -41,7 +42,11 @@ async def voice_response(message_voice: aiogram.types.Message): "We were unable to send you a voice message. Please check your privacy settings." ) else: - await message_voice.answer("Not recognized text") + error_text: str = await resp.text() + if error_text == "": + await message_voice.answer(f"Error: {resp.status}") + else: + await message_voice.answer(f"Error: {json.loads(error_text)['detail']}") await session.close() return