mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 10:01:04 +00:00
Handle all connector errors in search
This commit is contained in:
parent
99d09e3a70
commit
f11d64f984
1 changed files with 6 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue