use std::{io, path::PathBuf};
use thiserror::Error;
pub type MtagResult<T> = Result<T, MtagError>;
#[derive(Debug, Error)]
pub enum MtagError {
#[error("failed to scan music folder `{path}`: {source}")]
ReadDirectory {
path: PathBuf,
#[source]
source: io::Error,
},
#[error("failed to inspect file type `{path}`: {source}")]
InspectFileType {
path: PathBuf,
#[source]
source: io::Error,
},
#[error("failed to read metadata from `{path}`: {source}")]
ReadMetadata {
path: PathBuf,
#[source]
source: lofty::LoftyError,
},
#[error("no readable tags found in `{path}`")]
MissingTags {
path: PathBuf,
},
#[error("path `{path}` has no file name")]
MissingFileName {
path: PathBuf,
},
#[error("destination already exists `{path}`")]
DestinationExists {
path: PathBuf,
},
#[error("invalid conflict strategy `{value}`")]
InvalidConflictStrategy {
value: String,
},
#[error("invalid template variable `{variable}`")]
InvalidTemplateVariable {
variable: String,
},
#[error("unclosed template variable in `{template}`")]
UnclosedTemplateVariable {
template: String,
},
#[error("failed to {operation} `{from}` to `{to}`: {source}")]
FileOperation {
operation: &'static str,
from: PathBuf,
to: PathBuf,
#[source]
source: io::Error,
},
}