Skip to content

Commit

Permalink
error handling: include exec_info for better debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
ngc92 committed Jan 18, 2025
1 parent f280070 commit a279ee2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/discord-cluster-manager/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async def setup_hook(self):
commands = await self.tree.fetch_commands(guild=guild)
logger.info(f"Synced commands: {[cmd.name for cmd in commands]}")
except Exception as e:
logger.error(f"Failed to sync commands: {e}")
logger.error(f"Failed to sync commands: {e}", exc_info=e)

async def _setup_leaderboards(self): # noqa: C901
assert len(self.guilds) == 1, "Bot must be in only one guild"
Expand Down
7 changes: 4 additions & 3 deletions src/discord-cluster-manager/cogs/leaderboard_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ async def async_submit_cog_job(
+ f"Submission user: {user_id}.\n"
+ f"Runtime: {score:.9f} seconds.",
)
except Exception:
except Exception as e:
logger.error("Error in leaderboard submission", exc_info=e)
await discord_thread.send(
f"Leaderboard submission to '{leaderboard_name}' on {gpu.name} "
+ f"using {runner_name} runners failed!\n",
Expand Down Expand Up @@ -451,7 +452,7 @@ async def _get_submissions_helper(
)

except Exception as e:
logger.error(str(e))
logger.error(str(e), exc_info=e)
if "'NoneType' object is not subscriptable" in str(e):
await send_discord_message(
interaction,
Expand Down Expand Up @@ -692,7 +693,7 @@ async def leaderboard_create( # noqa: C901
ephemeral=True,
)
except Exception as e:
logger.error(f"Error in leaderboard creation: {e}")
logger.error(f"Error in leaderboard creation: {e}", exc_info=e)
# Handle any other errors
await send_discord_message(
interaction,
Expand Down
6 changes: 4 additions & 2 deletions src/discord-cluster-manager/cogs/misc_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ async def ping(self, interaction: discord.Interaction):

@app_commands.command(name="resync")
async def resync(self, interaction: discord.Interaction):
logger.info("Resyncing commands")

"""Admin command to resync slash commands"""
if interaction.user.guild_permissions.administrator:
try:
Expand All @@ -27,13 +29,13 @@ async def resync(self, interaction: discord.Interaction):
self.bot.tree.clear_commands(guild=interaction.guild)
await self.bot.tree.sync(guild=interaction.guild)
commands = await self.bot.tree.fetch_commands(guild=interaction.guild)
send_discord_message(
await send_discord_message(
interaction,
"Resynced commands:\n" + "\n".join([f"- /{cmd.name}" for cmd in commands]),
)
except Exception as e:
logger.error(f"Error in resync command: {str(e)}", exc_info=True)
send_discord_message(interaction, f"Error: {str(e)}")
await send_discord_message(interaction, f"Error: {str(e)}")
else:
await send_discord_message(
interaction, "You need administrator permissions to use this command"
Expand Down

0 comments on commit a279ee2

Please sign in to comment.