mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 18:11:09 +00:00
Better error handling and loggin in get_data
This commit is contained in:
parent
759a384852
commit
9a564a846a
1 changed files with 10 additions and 3 deletions
|
@ -210,13 +210,20 @@ def get_data(url):
|
||||||
'User-Agent': settings.USER_AGENT,
|
'User-Agent': settings.USER_AGENT,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
except (RequestError, SSLError):
|
except (RequestError, SSLError) as e:
|
||||||
|
logger.exception(e)
|
||||||
raise ConnectorException()
|
raise ConnectorException()
|
||||||
|
|
||||||
if not resp.ok:
|
if not resp.ok:
|
||||||
resp.raise_for_status()
|
try:
|
||||||
|
resp.raise_for_status()
|
||||||
|
except requests.exceptions.HTTPError as e:
|
||||||
|
logger.exception(e)
|
||||||
|
raise ConnectorException()
|
||||||
try:
|
try:
|
||||||
data = resp.json()
|
data = resp.json()
|
||||||
except ValueError:
|
except ValueError as e:
|
||||||
|
logger.exception(e)
|
||||||
raise ConnectorException()
|
raise ConnectorException()
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
Loading…
Reference in a new issue