use std::path::{PathBuf, StripPrefixError};
use fluent_i18n::t;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("{msg}", msg = t!("error-io-path", { "context" => context, "path" => path }))]
IoPath {
path: PathBuf,
context: &'static str,
source: std::io::Error,
},
#[error("{msg}", msg = t!("error-not-a-directory", { "path" => path }))]
NotADirectory {
path: PathBuf,
},
#[error("{msg}", msg = t!("error-non-absolute-paths", {
"paths" => paths.iter().fold(
String::new(),
|mut output, path| {
output.push_str(&format!("{path:?}\n"));
output
}
)
}))]
NonAbsolutePaths {
paths: Vec<PathBuf>,
},
#[error("{msg}", msg = t!("error-non-relative-paths", {
"paths" => paths.iter().fold(
String::new(),
|mut output, path| {
output.push_str(&format!("{path:?}\n"));
output
}
)
}))]
NonRelativePaths {
paths: Vec<PathBuf>,
},
#[error("{msg}\n{source}", msg = t!("error-path-strip-prefix", {
"prefix" => prefix,
"path" => path
}))]
PathStripPrefix {
prefix: PathBuf,
path: PathBuf,
source: StripPrefixError,
},
}