Better exception handling on the wekan client requests
C0rn3j opened this issue · 0 comments
C0rn3j commented
Currently the code does not care if the server is 502 and throws a generic exception.
It would be nice if it returned a more specific exception in the case of a connection failure that I could handle, instead of a generic JSON decode error.
python-wekan/wekan/wekan_client.py
Lines 103 to 139 in 413f91b
Exception has occurred: Exception (note: full exception trace is shown but execution is paused at: wekanLoop)
Could not decode the API response. Please see HTTP-Response:
<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.24.0</center>
</body>
</html>
StopIteration: 0
During handling of the above exception, another exception occurred:
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
File "main.py", line 577, in wekan
wekan = WekanClient(
^^^^^^^^^^^^
File "main.py", line 703, in wekanLoop (Current frame)
wekan()
Exception: Could not decode the API response. Please see HTTP-Response:
<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.24.0</center>
</body>
</html>