Connection Error handling
It seems to me that errors due to connection requests without response, see appearances of ConnError
and resp.status_code
. To reproduce, just disconnect from the network and run in the shell
iam persons --firstname Peter
I receive a somewhat ambiguously looking RequestsJSONDecodeError
.
Traceback (most recent call last):
File "site-packages/requests/models.py", line 971, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".virtualenvs/iam/bin/iam", line 8, in <module>
sys.exit(cli())
File "site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "ethz-iam-webservice/ethz_iam_webservice/main.py", line 122, in get_persons
found_persons = persons(
File "ethz-iam-webservice/ethz_iam_webservice/main.py", line 147, in persons
found_persons = iam.search_persons(
File "ethz-iam-webservice/ethz_iam_webservice/person.py", line 587, in search_persons
data = self.get_request(full_endpoint)
File "ethz-iam-webservice/ethz_iam_webservice/conn.py", line 66, in get_request
message = resp.json()
File "site-packages/requests/models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)