Description
A RustPanic occurs when passing a non-existent file to TIFF.open()
. Would it be possible to instead raise a FileNotFoundError
because this type of traceback would be unfamiliar to many Python users?
from async_tiff import TIFF
from async_tiff.store import LocalStore
import asyncio
file = "/Users/max/Documents/Code/maxrjones/virtual_tiff/tests/dvc/github/imaginary_file.tif" # Doesn't exist
store = LocalStore()
async def open_tiff(*, store, path):
return await TIFF.open(path, store=store)
tiff = asyncio.run(open_tiff(store=store, path=file))
print(tiff)
(base) max@Maxs-DevSeed-MacBook python % uv run .vscode/no-tiff.py
thread 'tokio-runtime-worker' panicked at src/tiff.rs:35:86:
called `Result::unwrap()` on an `Err` value: ObjectStore(NotFound { path: "/Users/max/Documents/Code/maxrjones/virtual_tiff/tests/dvc/github/imaginary_file.tif", source: Os { code: 2, kind: NotFound, message: "No such file or directory" } })
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
File "/Users/max/Documents/Code/developmentseed/async-tiff/python/.vscode/no-tiff.py", line 11, in <module>
tiff = asyncio.run(open_tiff(store=store, path=file))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/max/.local/share/uv/python/cpython-3.11.10-macos-aarch64-none/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/Users/max/.local/share/uv/python/cpython-3.11.10-macos-aarch64-none/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/max/.local/share/uv/python/cpython-3.11.10-macos-aarch64-none/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Users/max/Documents/Code/developmentseed/async-tiff/python/.vscode/no-tiff.py", line 9, in open_tiff
return await TIFF.open(path, store=store)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pyo3_async_runtimes.RustPanic: rust future panicked: unknown error
Metadata
Metadata
Assignees
Labels
No labels