Handle all connector errors in search

This commit is contained in:
Mouse Reeve 2021-04-07 08:09:47 -07:00
parent 99d09e3a70
commit f11d64f984
1 changed files with 6 additions and 1 deletions

View File

@ -1,5 +1,6 @@
""" interface with whatever connectors the app has """ """ interface with whatever connectors the app has """
import importlib import importlib
import logging
import re import re
from urllib.parse import urlparse from urllib.parse import urlparse
@ -11,6 +12,8 @@ from requests import HTTPError
from bookwyrm import models from bookwyrm import models
from bookwyrm.tasks import app from bookwyrm.tasks import app
logger = logging.getLogger(__name__)
class ConnectorException(HTTPError): class ConnectorException(HTTPError):
""" when the connector can't do what was asked """ """ when the connector can't do what was asked """
@ -44,7 +47,9 @@ def search(query, min_confidence=0.1):
if result_set in (None, []): if result_set in (None, []):
try: try:
result_set = connector.search(query, min_confidence=min_confidence) result_set = connector.search(query, min_confidence=min_confidence)
except (HTTPError, ConnectorException): except Exception as e: # pylint: disable=broad-except
# we don't want *any* error to crash the whole search page
logger.exception(e)
continue continue
# if the search results look the same, ignore them # if the search results look the same, ignore them