tonhowtf/omniget · error · anyhow::Error
anyhow!(e.to_string())
Error message
anyhow!(e.to_string())
What it means
This is a generic wrapper: lofty::read_from_path() failed to parse the audio file, and the library converts the lofty ParsingError into an anyhow error by stringifying it. It means the file could not be opened or decoded as a tagged audio format by the lofty crate — not a problem with the tags being edited, but with reading the file's existing metadata/container at all.
Solutions
- Confirm the file is a supported audio format (MP3, FLAC, M4A, OGG, WAV, etc.) and plays in a normal player.
- Re-obtain or re-download the file if it is truncated or corrupt (check size > 0 and intact header).
- Improve the error by using with_context to keep the path alongside lofty's message: .map_err(|e| anyhow!("falha ao ler {}: {e}", path)).
- Match on lofty's error kind to give distinct messages for unsupported vs malformed input instead of e.to_string().
Example fix
// before
let mut tagged = lofty::read_from_path(path).map_err(|e| anyhow!(e.to_string()))?;
// after
let mut tagged = lofty::read_from_path(path)
.with_context(|| format!("falha ao ler tags de {}: {e}", path))?; Defensive patterns
Strategy: try-catch
Validate before calling
fn readable_audio(path: &str) -> bool {
std::path::Path::new(path).is_file() && std::fs::metadata(path).map(|m| m.len() > 0).unwrap_or(false)
} Try / catch
match lofty::read_from_path(path) {
Ok(tagged) => /* editar tags */,
Err(e) => eprintln!("arquivo de áudio ilegível/corrompido ({path}): {e}"),
} Prevention
- Check the file exists, is non-empty, and is a known audio extension before tagging.
- Re-download or restore corrupt files instead of retrying edits.
- Keep lofty updated; log e.to_string() with the path for diagnosis.
- Validate library entries against the filesystem to prune stale paths.
When it happens
Trigger: Calling the tag-editing function on a path whose file lofty cannot parse: unsupported container, corrupted headers, zero-byte or truncated file, or a non-audio file passed as path.
Common situations: Pointing the tool at a partially downloaded MP3, a DRM-protected or unusual-format file, a renamed non-audio file, or a path that now points to an empty file.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- o formato não aceita a tag {tag_type:?}
- a capa {cover} não é PNG, JPEG, GIF ou BMP
- Track sem soundcloud_id
- SoundCloud nao retornou URL
- Spotify SDK device not ready
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/5239bd5a1b00711a.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/audio_tag.rs:1238
diffs: diffs.to_vec(),
cover: None,
unsupported: Vec::new(),
written: false,
backup: None,
error: None,
};
let cover_bytes = if let Some(cover) = opts.cover_path.as_deref().filter(|s| !s.is_empty()) {
let data =
std::fs::read(cover).with_context(|| format!("não consegui ler a capa em {cover}"))?;
let mime =
mime_of(&data).ok_or_else(|| anyhow!("a capa {cover} não é PNG, JPEG, GIF ou BMP"))?;
Some((data, mime))
} else {
None
};
let mut tagged = lofty::read_from_path(path).map_err(|e| anyhow!(e.to_string()))?;
let tag_type = tagged.primary_tag_type();
if tagged.primary_tag_mut().is_none() {
tagged.insert_tag(Tag::new(tag_type));
}
let tag = tagged
.primary_tag_mut()
.ok_or_else(|| anyhow!("o formato não aceita a tag {tag_type:?}"))?;
let before_cover = tag.pictures().len();
let before_bytes: u64 = tag.pictures().iter().map(|p| p.data().len() as u64).sum();
change.unsupported = apply_diffs(tag, diffs);
if opts.remove_cover {
while !tag.pictures().is_empty() {
let _ = tag.remove_picture(0);
}
change.cover = Some(CoverDiff {View on GitHub (pinned to 8600b91f42)