Catch error response decoding json in search connector

This commit is contained in:
Mouse Reeve 2020-12-30 09:11:00 -08:00
parent 26c0880fe4
commit 21f67c9e28
2 changed files with 6 additions and 2 deletions

View file

@ -5,6 +5,7 @@ from urllib.parse import urlparse
from requests import HTTPError
from bookwyrm import models
from bookwyrm.connectors import ConnectorException
from bookwyrm.tasks import app
@ -55,7 +56,7 @@ def search(query, min_confidence=0.1):
for connector in get_connectors():
try:
result_set = connector.search(query, min_confidence=min_confidence)
except HTTPError:
except (HTTPError, ConnectorException):
continue
result_set = [r for r in result_set \

View file

@ -46,7 +46,10 @@ class AbstractMinimalConnector(ABC):
)
if not resp.ok:
resp.raise_for_status()
data = resp.json()
try:
data = resp.json()
except ValueError as e:
raise ConnectorException('Unable to parse json response', e)
results = []
for doc in self.parse_search_data(data)[:10]: