Repository navigation
Improve error reporting with structured errors and filename context - #2
Merged
Merged
Conversation
Replace anyhow::Result in fingerprint_file() with a typed FingerprintError enum (OpenFailed, UnrecognizedFormat, NoAudioTrack, DecodeFailed, EmptyFingerprint) that provides user-friendly Display messages. Promote scanner error logging from debug! to warn! so users see which file failed and why at default verbosity. Demote symphonia's internal tracing (which lacks file context) to debug level. Fixes #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1 — errors during scanning now include the filename and a clear explanation of what went wrong.
Before
No filename. No explanation. Repeated every few files.
After
Changes
src/fingerprint.rs: Replaceanyhow::Resultwith a typedFingerprintErrorenum:OpenFailed— permission denied, file locked, etc.UnrecognizedFormat— not valid audio or too short to probeNoAudioTrack— container has no audio streamDecodeFailed— unsupported or corrupted codecEmptyFingerprint— silence or too short for fingerprintingsrc/scanner.rs: Promote error log fromdebug!towarn!so it's visible at default verbosity, with the filename and user-friendly message.src/main.rs: Demote symphonia's internal tracing to debug level (still visible with-vv).tests/integration_test.rs: Add 5 tests verifying correct error variants are returned for nonexistent files, non-audio files, truncated files, empty files, and that Display messages are user-friendly.Testing
All 53 tests pass (
cargo test).