Skip to content

Commit

Permalink
improve BetterBibtex error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
plandes committed Sep 18, 2024
1 parent b0157b8 commit 1b3bcc3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/python/zensols/zotsite/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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':
Expand Down
8 changes: 7 additions & 1 deletion src/python/zensols/zotsite/cite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))

0 comments on commit 1b3bcc3

Please sign in to comment.