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

View file

@ -1,5 +1,6 @@
""" interface with whatever connectors the app has """
import importlib
import logging
import re
from urllib.parse import urlparse
@ -11,6 +12,8 @@ from requests import HTTPError
from bookwyrm import models
from bookwyrm.tasks import app
logger = logging.getLogger(__name__)
class ConnectorException(HTTPError):
""" 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, []):
try:
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
# if the search results look the same, ignore them