From 04ac88cfa41dbc5cde5d7215681f654dea1f76ad Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 20 Jun 2022 10:38:24 +0530 Subject: [PATCH] Better failure mode for unknown book/author --- src/calibre/gui2/fts/search.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/calibre/gui2/fts/search.py b/src/calibre/gui2/fts/search.py index 0bcfde6a2f..44e9edacd9 100644 --- a/src/calibre/gui2/fts/search.py +++ b/src/calibre/gui2/fts/search.py @@ -95,19 +95,17 @@ class Results: @property def title(self): if self._title is None: - try: + with suppress(Exception): self._title = get_db().field_for('title', self.book_id) - except Exception: - self._title = _('Unknown book') + self._title = self._title or _('Unknown book') return self._title @property def authors(self): if self._authors is None: - try: + with suppress(Exception): self._authors = get_db().field_for('authors', self.book_id) - except Exception: - self._authors = _('Unknown author'), + self._authors = self._authors or [_('Unknown author')] return self._authors @property @@ -585,7 +583,7 @@ class ResultDetails(QWidget): t = results.title if len(t) > 72: t = t[:71] + '…' - text = f'

{prepare_string_for_xml(results.title)}
' + text = f'

{prepare_string_for_xml(t)}
' au = results.authors if len(au) > 3: au = list(au[:3]) + ['…']