diff --git a/src/python/zensols/zotsite/app.py b/src/python/zensols/zotsite/app.py index 5c42bad..90e5521 100644 --- a/src/python/zensols/zotsite/app.py +++ b/src/python/zensols/zotsite/app.py @@ -10,8 +10,7 @@ import sys import json from pathlib import Path -from zensols.cli import ApplicationError -from . import SiteCreator, CiteDatabase +from . import ZoteroApplicationError, SiteCreator, CiteDatabase logger = logging.getLogger(__name__) @@ -81,7 +80,7 @@ def lookup(self, format: str = '{itemKey}={citationKey}', key: str = None): keys = [key] for key in keys: if key not in entries: - raise ApplicationError( + raise ZoteroApplicationError( f"No such entry: '{key}' in BetterBibtex database") entry: Dict[str, Any] = entries[key] if format == 'json': diff --git a/src/python/zensols/zotsite/cite.py b/src/python/zensols/zotsite/cite.py index 74c0551..5c8b1fa 100644 --- a/src/python/zensols/zotsite/cite.py +++ b/src/python/zensols/zotsite/cite.py @@ -5,7 +5,9 @@ from typing import Tuple, Dict, Any from dataclasses import dataclass, field +from sqlite3 import OperationalError from zensols.db import DbPersister +from . import ZoteroApplicationError @dataclass @@ -30,5 +32,9 @@ def map_row(r: Tuple[Any, ...]) -> Tuple[str, Dict[str, Any]]: data = {'libraryID': r[0], 'itemKey': r[1], 'citationKey': r[2]} return key, data - rows: Tuple[Tuple[str]] = self._persister.execute(self._sql) + try: + rows: Tuple[Tuple[str]] = self._persister.execute(self._sql) + except OperationalError as e: + raise ZoteroApplicationError( + f'Could not access BetterBibtex database: {e}') from e return dict(map(map_row, rows))