From 67f88c7a76d732e5e6d283eb1a24fbf12b766148 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Sun, 22 May 2022 22:26:57 +0100 Subject: Use existing ResponseCodeError attrs rather than fetch again This also updates the log string to use % based format strings, rather than a mix of f-string and % string which caused the %r to not work. --- bot/exts/backend/error_handler.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bot/exts/backend/error_handler.py b/bot/exts/backend/error_handler.py index 35dddd8dc..194a4889d 100644 --- a/bot/exts/backend/error_handler.py +++ b/bot/exts/backend/error_handler.py @@ -284,8 +284,11 @@ class ErrorHandler(Cog): await ctx.send("There does not seem to be anything matching your query.") ctx.bot.stats.incr("errors.api_error_404") elif e.status == 400: - content = await e.response.json() - log.error(f"API responded with 400 for command {ctx.command}: %r.", content) + log.error( + "API responded with 400 for command %s: %r.", + ctx.command, + e.response_json or e.response_text, + ) await ctx.send("According to the API, your request is malformed.") ctx.bot.stats.incr("errors.api_error_400") elif 500 <= e.status < 600: -- cgit v1.2.3