Handle weekend errors
parent
1af14bc46f
commit
488f3988ea
|
@ -40,7 +40,8 @@ def resproc(
|
||||||
try:
|
try:
|
||||||
data = resp.json()
|
data = resp.json()
|
||||||
except json.decoder.JSONDecodeError:
|
except json.decoder.JSONDecodeError:
|
||||||
log.exception(f"Failed to process {resp}")
|
log.exception(f"Failed to process {resp}:\n{resp.text}")
|
||||||
|
raise QuestradeError(resp.text)
|
||||||
else:
|
else:
|
||||||
log.debug(f"Received json contents:\n{colorize_json(data)}")
|
log.debug(f"Received json contents:\n{colorize_json(data)}")
|
||||||
|
|
||||||
|
@ -124,8 +125,12 @@ class Client:
|
||||||
try:
|
try:
|
||||||
data = await self._new_auth_token()
|
data = await self._new_auth_token()
|
||||||
except QuestradeError as qterr:
|
except QuestradeError as qterr:
|
||||||
|
if "We're making some changes" in qterr.args[0]:
|
||||||
|
# API service is down
|
||||||
|
raise QuestradeError("API is down for maintenance")
|
||||||
|
|
||||||
|
elif qterr.args[0].decode() == 'Bad Request':
|
||||||
# likely config ``refresh_token`` is expired
|
# likely config ``refresh_token`` is expired
|
||||||
if qterr.args[0].decode() == 'Bad Request':
|
|
||||||
_token_from_user(self._conf)
|
_token_from_user(self._conf)
|
||||||
self._apply_config(self._conf)
|
self._apply_config(self._conf)
|
||||||
data = await self._new_auth_token()
|
data = await self._new_auth_token()
|
||||||
|
|
Loading…
Reference in New Issue