better error printing

This commit is contained in:
yuki 2025-10-07 06:04:32 -03:00
parent 8434b244e3
commit c1df6ba018

View file

@ -13,7 +13,7 @@ def setup(bot: bot.Bot):
try: username = await bot.get_lastfm(ctx.author.id)
except Exception as e:
print(e)
await ctx.send(u.error_msg("Unknown database error."))
await ctx.send(u.error_msg(f"Unknown database error:\n{e}"))
if not username:
await ctx.send(u.error_msg("Please provide a Last.fm username (or set yours with `/setfm`)"))
@ -41,12 +41,13 @@ def setup(bot: bot.Bot):
except IndexError:
await ctx.send(u.error_msg(f"User **{username}** has no recent tracks or they're set to private."))
except pylast.WSError:
await ctx.send(u.error_msg(f"User **{username}** not found."))
except pylast.WSError as e:
print(e)
await ctx.send(u.error_msg(f"Last.fm error:\n`{e}`"))
except Exception as e:
print(e)
await ctx.send(u.error_msg("Unknown error."))
await ctx.send(u.error_msg(f"Unknown error:\n`{e}`"))
@bot.command(name="cover", aliases=["coverart","art"])
@bot.slash_command(name="cover", description="Returns cover art of last played album or a custom query.")
@ -77,7 +78,7 @@ def setup(bot: bot.Bot):
except Exception as e:
print(e)
await ctx.send(u.error_msg("Unknown error."))
await ctx.send(u.error_msg(f"Unknown error:\n`{e}`"))
else:
try:
if "|" not in album:
@ -96,9 +97,10 @@ def setup(bot: bot.Bot):
f"Here's the cover art for **[{albumobj.get_name(properly_capitalized=True)}]({albumobj.get_url()})**:\
{cover_art}"
)
except pylast.WSError as e:
print(e)
await ctx.send(u.error_msg(e))
await ctx.send(u.error_msg(f"Last.fm error:\n`{e}`"))
except Exception as e:
print(e)
await ctx.send(u.error_msg("Unknown parsing error."))
await ctx.send(u.error_msg(f"Unknown parsing error:\n`{e}`"))