Skip to content

feat: a missing image file raises FileNotFoundError, with a short traceback and suggestions - #328

Merged
petercorke merged 2 commits into
mainfrom
fix/missing-file-error
Nov 27, 2026
Merged

petercorke merged 2 commits into
mainfrom
fix/missing-file-error

Conversation

@petercorke

@petercorke petercorke commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

A missing image file gave a long traceback and an unreadable last line, file ('images', PosixPath('flowers.png')) not found locally or in mvtbdata (...). It now raises FileNotFoundError with a message that names the file as written and suggests similar names:

FileNotFoundError: file 'flowers.png' not found in the current folder or in mvtbdata/images; did you mean flowers1.png, flowers2.png, flowers3.png?
  • Image.Read and iread re-raise the error so the traceback is the caller's line and one Read frame, not four.
  • mvtb_path_to_datafile and the mvtb_load_* loaders raise FileNotFoundError, as their docstrings already said.
  • Callers that caught ValueError for a missing file now catch FileNotFoundError too: the file picker, imtool, ocrtool, tagtool, the ROS bag loader and one test helper.
  • Image.Read and iread have .. versionchanged:: 2.5.0 notes.

Behavior change

Code that catches ValueError for a missing file must catch FileNotFoundError. This goes in as a plain feat, with no !. A wildcard that matches nothing still raises ValueError, which I left alone.

Testing

Full suite: 2684 passed, 30 skipped, plus one test that expected ValueError, now updated and passing. mypy is clean. New tests cover the message, the suggestions, the one-frame traceback and iread.

This change was written with Claude Code, and I have read the diff.

🤖 Generated with Claude Code

petercorke and others added 2 commits November 27, 2026 16:44
…ceback and suggestions

Image.Read, iread and mvtb_path_to_datafile raised ValueError with a message
showing a tuple and a PosixPath, from the bottom of a four-frame traceback.
They now raise FileNotFoundError naming the file as written, suggest similar
file names from mvtbdata, and Image.Read and iread end the traceback at the
call. Code that caught ValueError for a missing file must catch
FileNotFoundError.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 16 complexity · 0 duplication

Metric Results
Complexity 16
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@petercorke
petercorke merged commit 06d2e95 into main Nov 27, 2026
35 checks passed
@petercorke
petercorke deleted the fix/missing-file-error branch November 27, 2026 07:20
@github-actions github-actions Bot mentioned this pull request Nov 27, 2026
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.

1 participant