Skip to content

Improve error reporting with structured errors and filename context - #2

Merged
zas merged 1 commit into
mainfrom
fix/improve-error-reporting
Jul 10, 2026
Merged

zas merged 1 commit into
mainfrom
fix/improve-error-reporting

Conversation

@zas

@zas zas commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #1 — errors during scanning now include the filename and a clear explanation of what went wrong.

Before

2026-07-10T11:42:29.259989Z ERROR symphonia_core::formats::probe: probe reached EOF at 4096 bytes

No filename. No explanation. Repeated every few files.

After

WARN dupsonic::scanner: Skipping /home/user/Music/broken.mp3: not a recognized audio format or file is too short/corrupted (end of stream)

Changes

  • src/fingerprint.rs: Replace anyhow::Result with a typed FingerprintError enum:

    • OpenFailed — permission denied, file locked, etc.
    • UnrecognizedFormat — not valid audio or too short to probe
    • NoAudioTrack — container has no audio stream
    • DecodeFailed — unsupported or corrupted codec
    • EmptyFingerprint — silence or too short for fingerprinting
  • src/scanner.rs: Promote error log from debug! to warn! 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).

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
@zas
zas merged commit 9e39a0a into main Jul 10, 2026
5 checks passed
@zas
zas deleted the fix/improve-error-reporting branch July 10, 2026 12:17
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.

Unhelpful errors

1 participant