aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-09-16 16:23:14 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:54 +0100
commit748991ae4d0bf3726b4a1eeb851b2d3a6446b2bb (patch)
tree5ac2479ecc4abc2ef96c5d38eafc26f1d90ccf2d
parent30eea6bb1f4278b79583e8130aef5e404411a31b (diff)
downloadwee-slack-748991ae4d0bf3726b4a1eeb851b2d3a6446b2bb.tar.gz
Use None instead of 0 for missing http code in HttpError
-rw-r--r--slack/error.py2
-rw-r--r--slack/http.py2
-rw-r--r--tests/test_http_request.py6
3 files changed, 5 insertions, 5 deletions
diff --git a/slack/error.py b/slack/error.py
index 7a38f29..80af53d 100644
--- a/slack/error.py
+++ b/slack/error.py
@@ -21,7 +21,7 @@ class HttpError(Exception):
url: str,
options: Dict[str, str],
return_code: int,
- http_status_code: int,
+ http_status_code: Optional[int],
error: str,
):
super().__init__(
diff --git a/slack/http.py b/slack/http.py
index 5909cc0..b05cfb4 100644
--- a/slack/http.py
+++ b/slack/http.py
@@ -76,7 +76,7 @@ async def http_request(
)
await sleep(1000)
return await http_request(url, options, timeout, max_retries - 1)
- raise HttpError(url, options, return_code, 0, err)
+ raise HttpError(url, options, return_code, None, err)
parts = out.split("\r\n\r\nHTTP/")
last_header_part, body = parts[-1].split("\r\n\r\n", 1)
diff --git a/tests/test_http_request.py b/tests/test_http_request.py
index a9e941d..1a0b4a0 100644
--- a/tests/test_http_request.py
+++ b/tests/test_http_request.py
@@ -49,7 +49,7 @@ def test_http_request_error_process_return_code():
assert excinfo.value.url == url
assert excinfo.value.return_code == -2
- assert excinfo.value.http_status_code == 0
+ assert excinfo.value.http_status_code == None
assert excinfo.value.error == ""
@@ -66,7 +66,7 @@ def test_http_request_error_process_stderr():
assert excinfo.value.url == url
assert excinfo.value.return_code == 0
- assert excinfo.value.http_status_code == 0
+ assert excinfo.value.http_status_code == None
assert excinfo.value.error == "err"
@@ -143,7 +143,7 @@ def test_http_request_error_retry_error():
assert excinfo.value.url == url
assert excinfo.value.return_code == -2
- assert excinfo.value.http_status_code == 0
+ assert excinfo.value.http_status_code == None
assert excinfo.value.error == ""