Skip to content

Commit 0e493ba

Browse files
tobiasdiezjamesbrazapre-commit-ci-lite[bot]
authored
Add error handling for index file loading in SearchIndex (#948)
Co-authored-by: James Braza <jamesbraza@gmail.com> Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 3cbc4dd commit 0e493ba

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

paperqa/agents/search.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,15 @@ async def index_files(self) -> dict[str, str]:
258258
if await file_index_path.exists():
259259
async with await anyio.open_file(file_index_path, "rb") as f:
260260
content = await f.read()
261-
self._index_files = pickle.loads( # noqa: S301
262-
zlib.decompress(content)
263-
)
261+
try:
262+
self._index_files = pickle.loads( # noqa: S301
263+
zlib.decompress(content)
264+
)
265+
except Exception:
266+
logger.exception(
267+
f"Failed to load index file {file_index_path}."
268+
)
269+
raise
264270
return self._index_files
265271

266272
@staticmethod

0 commit comments

Comments
 (0)