tejado / pgoapi

Pokemon Go API lib
Other
1.4k stars 445 forks source link

JSONDecodeError, when the API is down #79

Closed Wegi closed 8 years ago

Wegi commented 8 years ago

This error gets thrown, when the Servers are down:

if not self._auth_provider.login(username, password):
  File "/home/wegi/.virtualenvs/poke-cruncher/src/pgoapi/pgoapi/auth_ptc.py", line 56, in login
    jdata = json.loads(r.content.decode('utf-8'))
  File "/usr/lib64/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python3.5/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 3 column 1 (char 2)

Maybe add a softfail or a specific exception which can be caught, when server responses are abnormal.

tejado commented 8 years ago

should be implemented now.