From 536cae3e56db4d8ffa751def331f2f42fe19a7fe Mon Sep 17 00:00:00 2001 From: Esteban Vincent Date: Thu, 23 Oct 2025 15:25:42 +0200 Subject: [PATCH] =?UTF-8?q?fix(meme):=20improve=20exception=20handling=20a?= =?UTF-8?q?nd=20traceback=20reporting=20=F0=9F=90=9B=20Updated=20the=20exc?= =?UTF-8?q?eption=20handling=20in=20the=20meme=20command=20to=20include=20?= =?UTF-8?q?traceback=20details=20in=20the=20response.=20This=20change=20he?= =?UTF-8?q?lps=20in=20diagnosing=20issues=20more=20effectively=20by=20prov?= =?UTF-8?q?iding=20the=20full=20traceback=20as=20a=20file=20attachment.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit *Generated by Github Copilot* --- src/main.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main.py b/src/main.py index c55447e..574ed82 100644 --- a/src/main.py +++ b/src/main.py @@ -1,4 +1,5 @@ import os +import traceback import discord import httpx @@ -53,13 +54,18 @@ async def meme(interaction: discord.Interaction, prompt: str): ) await interaction.followup.send(embed=embed) - except Exception as e: + except Exception: + exception_traceback = traceback.format_exc() embed = discord.Embed( title="Exception", - description=str(e), + description="See attached exception traceback", color=0xFF0000, ) - await interaction.followup.send(embed=embed) + # Send error details as a file attachment to bypass character limits + error_file = discord.File( + fp=bytes(exception_traceback, "utf-8"), filename="exception_traceback.txt" + ) + await interaction.followup.send(embed=embed, file=error_file) client.run(os.getenv("DISCORD_TOKEN"))