From 1c21f674c2eab52b7273a06f83519c2a8ce55c6d Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Wed, 25 Mar 2026 16:44:20 -0500 Subject: [PATCH] fix: add error logging and user-facing message for API failures - Log API error detail when refractor endpoint returns an error - Show "Something went wrong" instead of misleading "No refractor data" - Log empty response case for debugging Co-Authored-By: Claude Opus 4.6 (1M context) --- cogs/refractor.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cogs/refractor.py b/cogs/refractor.py index a1f2f63..00ac2b7 100644 --- a/cogs/refractor.py +++ b/cogs/refractor.py @@ -181,11 +181,24 @@ class Refractor(commands.Cog): data = await db_get("refractor/cards", params=params) if not data: + logger.error( + "Refractor API returned empty response for team %s", team["id"] + ) await interaction.edit_original_response( content="No refractor data found for your team." ) return + # API error responses contain "detail" key + if isinstance(data, dict) and "detail" in data: + logger.error( + "Refractor API error for team %s: %s", team["id"], data["detail"] + ) + await interaction.edit_original_response( + content="Something went wrong fetching refractor data. Please try again later." + ) + return + items = data if isinstance(data, list) else data.get("items", []) total_count = ( data.get("count", len(items)) if isinstance(data, dict) else len(items)