apqlzm / medihunter

Find Medicover appointments
GNU General Public License v3.0
167 stars 63 forks source link

`JSONDecodeError: Expecting value` after some while #49

Open wrobelda opened 1 year ago

wrobelda commented 1 year ago

I got a JSONDecodeError: Expecting value error followed by a crash after some 100+ iterations. I possibly got throttled, since I set up a relative short interval. Nonetheless, it would be nice if the tool: 1) console-printed the top n lines of the JSON it actually received 2) sent a regular notification about the error 3) maybe increased an interval gradually until it received a valid JSON again, instead of quitting cowardly

Traceback I got:

Traceback (most recent call last):
  File "/home/medicover/medihunter/venv/lib/python3.10/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 "/home/medicover/medihunter/venv/bin/medihunter", line 33, in <module>
    sys.exit(load_entry_point('medihunter', 'console_scripts', 'medihunter')())
  File "/home/medicover/medihunter/venv/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/medicover/medihunter/venv/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/medicover/medihunter/venv/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/medicover/medihunter/venv/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/medicover/medihunter/venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/medicover/medihunter/medihunter.py", line 170, in find_appointment
    found_appointments = med_session.search_appointments(
  File "/home/medicover/medihunter/medicover_session.py", line 304, in search_appointments
    appointments = self._parse_search_results(result)
  File "/home/medicover/medihunter/medicover_session.py", line 223, in _parse_search_results
    result = result.json()
  File "/home/medicover/medihunter/venv/lib/python3.10/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)