Skip to content

Raise FileNotFoundError instead of panic when opening missing files #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 6, 2025

Conversation

weiji14
Copy link
Member

@weiji14 weiji14 commented May 1, 2025

What I am changing

  • Avoid panic when non-existent file is passed into TIFF.open

How I did it

  • Replace .unwrap() with .map_err(|err| PyFileNotFoundError::new_err(err.to_string()))?
  • Add unit test to ensure FileNotFoundError is raised for missing files

How you can test it

Related Issues

Fixes #90

@@ -32,7 +32,9 @@ impl PyTIFF {
let reader = store.into_async_file_reader(path);

let cog_reader = future_into_py(py, async move {
let metadata_fetch = PrefetchBuffer::new(reader.clone(), prefetch).await.unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we should remove all of these unwraps, but we can leave that for the future.

@weiji14 weiji14 marked this pull request as ready for review May 6, 2025 22:20
@weiji14 weiji14 merged commit 58fcf88 into main May 6, 2025
6 checks passed
@weiji14 weiji14 deleted the raise_filenotfounderror branch May 6, 2025 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Raise NotFoundError rather than panic on non-existent file
2 participants