From f13b8b0f5748c997f29030dcc4b005e7120e50df Mon Sep 17 00:00:00 2001 From: ned Date: Sun, 5 Mar 2023 20:12:49 +0100 Subject: [PATCH] send exception errors to result text --- telegram_bot.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/telegram_bot.py b/telegram_bot.py index 40a47eb..8a23b35 100644 --- a/telegram_bot.py +++ b/telegram_bot.py @@ -75,11 +75,11 @@ class ChatGPT3TelegramBot: reply_to_message_id=update.message.message_id, photo=image_url ) - except: + except Exception as e: await context.bot.send_message( chat_id=chat_id, reply_to_message_id=update.message.message_id, - text='Failed to generate image' + text=f'Failed to generate image: {str(e)}' ) async def transcribe(self, update: Update, context: ContextTypes.DEFAULT_TYPE): @@ -128,11 +128,11 @@ class ChatGPT3TelegramBot: text=transcript, parse_mode=constants.ParseMode.MARKDOWN ) - except: + except Exception as e: await context.bot.send_message( chat_id=chat_id, reply_to_message_id=update.message.message_id, - text='Failed to transcribe text' + text=f'Failed to transcribe text: {str(e)}' ) finally: