From 75dfe365cc7b5ec4263ca7fb03324274b5105b45 Mon Sep 17 00:00:00 2001 From: Esteban Vincent Date: Thu, 23 Oct 2025 16:14:52 +0200 Subject: [PATCH] =?UTF-8?q?fix(meme):=20improve=20exception=20handling=20f?= =?UTF-8?q?or=20traceback=20reporting=20=F0=9F=90=9B=20Refactor=20exceptio?= =?UTF-8?q?n=20handling=20to=20capture=20and=20format=20the=20traceback=20?= =?UTF-8?q?more=20effectively,=20ensuring=20detailed=20error=20information?= =?UTF-8?q?=20is=20sent=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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.py b/src/main.py index c34eef3..2c855b6 100644 --- a/src/main.py +++ b/src/main.py @@ -55,8 +55,8 @@ async def meme(interaction: discord.Interaction, prompt: str): ) await interaction.followup.send(embed=embed) - except Exception: - exception_traceback = traceback.format_exc() + except Exception as exc: + tb = "".join(traceback.format_exception(type(exc), exc, exc.__traceback__)) embed = discord.Embed( title="Exception", description="See attached exception traceback", @@ -64,7 +64,7 @@ async def meme(interaction: discord.Interaction, prompt: str): ) # Send error details as a file attachment to bypass character limits error_file = discord.File( - fp=io.BytesIO(bytes(exception_traceback, "utf-8")), + fp=io.BytesIO(bytes(tb, "utf-8")), filename="exception_traceback.txt", ) await interaction.followup.send(embed=embed, file=error_file)