From 2fc059e2f3c63c0f486e9993116778a8835f567a Mon Sep 17 00:00:00 2001 From: Hanne Moa Date: Fri, 24 Jan 2025 15:43:40 +0100 Subject: [PATCH] dump content of response if exists --- src/argus/htmx/middleware.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/argus/htmx/middleware.py b/src/argus/htmx/middleware.py index 7b47940e4..d2190adf5 100644 --- a/src/argus/htmx/middleware.py +++ b/src/argus/htmx/middleware.py @@ -97,7 +97,9 @@ def process_response(self, request: HtmxHttpRequest, response: HttpResponse) -> has_error_message = any("error" in message.tags for message in storage) storage.used = False if not has_error_message: - error_msg = f"{response.status_code} {response.reason_phrase}" + error_msg = str(getattr(response, "content", b"")) + if not error_msg: + error_msg = f"{response.status_code} {response.reason_phrase}" messages.error( request, f"An error occured while processing your request, please try again: {error_msg}" )