From a4e25ab72710c95feef75651d3d4e5fe81fb249d Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sun, 8 Oct 2023 14:49:45 +0200 Subject: Raise error if both error and response_code is missing I experienced a KeyError on response_code and not sure when that could happen, so log the output to check it if it happens again. --- slack/http.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'slack') diff --git a/slack/http.py b/slack/http.py index 49b361e..85c9be3 100644 --- a/slack/http.py +++ b/slack/http.py @@ -94,6 +94,15 @@ async def http_request_url( if "error" in output: raise HttpError(url, options, None, None, output["error"]) + if "response_code" not in output: + raise HttpError( + url, + options, + None, + None, + f"Unexpectedly missing response_code, output: {output}", + ) + http_status = int(output["response_code"]) header_parts = output["headers"].split("\r\n\r\nHTTP/") return http_status, header_parts[-1], output["output"] -- cgit