Skip to content

invalid JSON response from Poloniex is not parsed correctly #111

@ethene

Description

@ethene

Hello,
sometimes the requests could not be completed correctly (may be due to DDOS or rate limit violation?), and apparently Poloniex responds with something that could not be parsed by your wrapper:

balances = self.polo.returnAvailableAccountBalances()

File "/home/strky/anaconda3/envs/py36/lib/python3.6/site-packages/poloniex/init.py", line 449, in returnAvailableAccountBalances
return self.call('returnAvailableAccountBalances')
File "/home/strky/anaconda3/envs/py36/lib/python3.6/site-packages/poloniex/retry.py", line 15, in wrapped
return function(*args, **kwargs)
File "/home/strky/anaconda3/envs/py36/lib/python3.6/site-packages/poloniex/init.py", line 175, in call
jsonout = _loads(ret.text, parse_float=str)
File "/home/strky/anaconda3/envs/py36/lib/python3.6/json/init.py", line 367, in loads
return cls(**kw).decode(s)
File "/home/strky/anaconda3/envs/py36/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/home/strky/anaconda3/envs/py36/lib/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Is it possible to wrap the json decoding into try/except and return the error with original text to aid troubleshooting?
Other solutions might be possible...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is not behaving as it should in the code

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions