From 94d5986ff21166aed5df3d26a1086af1125b7b56 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 30 Sep 2020 20:09:25 -0700 Subject: [PATCH] More error handling in connector/books manager --- bookwyrm/books_manager.py | 4 +++- bookwyrm/connectors/abstract_connector.py | 3 +++ bookwyrm/connectors/self_connector.py | 4 ---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bookwyrm/books_manager.py b/bookwyrm/books_manager.py index c18e6361..bfc543de 100644 --- a/bookwyrm/books_manager.py +++ b/bookwyrm/books_manager.py @@ -26,8 +26,10 @@ def get_or_create_book(remote_id): connector = get_or_create_connector(remote_id) + # raises ConnectorException book = connector.get_or_create_book(remote_id) - load_more_data.delay(book.id) + if book: + load_more_data.delay(book.id) return book diff --git a/bookwyrm/connectors/abstract_connector.py b/bookwyrm/connectors/abstract_connector.py index 387b994f..9d687a80 100644 --- a/bookwyrm/connectors/abstract_connector.py +++ b/bookwyrm/connectors/abstract_connector.py @@ -132,6 +132,9 @@ class AbstractConnector(ABC): edition.author_text = work.author_text edition.save() + if not edition: + raise ConnectorException('Unable to create book: %s' % remote_id) + return edition diff --git a/bookwyrm/connectors/self_connector.py b/bookwyrm/connectors/self_connector.py index e1317597..2711bb1a 100644 --- a/bookwyrm/connectors/self_connector.py +++ b/bookwyrm/connectors/self_connector.py @@ -50,10 +50,6 @@ class Connector(AbstractConnector): ) - def get_or_create_book(self, remote_id): - ''' this COULD be semi-implemented but I think it shouldn't be used ''' - - def is_work_data(self, data): pass