mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 19:41:11 +00:00
handle get_data exceptions better
Makes exception handling more precise, only raising status for 401s. Also fixes a string pylint was complaining about.
This commit is contained in:
parent
f8c9df4aff
commit
e8452011f7
2 changed files with 7 additions and 2 deletions
|
@ -306,7 +306,8 @@ def resolve_remote_id(
|
|||
|
||||
|
||||
def get_representative():
|
||||
"""Get or create an actor representing the entire instance to sign requests to 'secure mastodon' servers"""
|
||||
"""Get or create an actor representing the instance
|
||||
to sign requests to 'secure mastodon' servers"""
|
||||
username = f"{INSTANCE_ACTOR_USERNAME}@{DOMAIN}"
|
||||
try:
|
||||
user = models.User.objects.get(username=username)
|
||||
|
|
|
@ -244,7 +244,11 @@ def get_data(url, params=None, timeout=settings.QUERY_TIMEOUT):
|
|||
raise ConnectorException(err)
|
||||
|
||||
if not resp.ok:
|
||||
resp.raise_for_status()
|
||||
if resp.status_code == 401:
|
||||
# this is probably an AUTHORIZED_FETCH issue
|
||||
resp.raise_for_status()
|
||||
else:
|
||||
raise ConnectorException()
|
||||
try:
|
||||
data = resp.json()
|
||||
except ValueError as err:
|
||||
|
|
Loading…
Reference in a new issue