1use std::path::{PathBuf, StripPrefixError};
2
3use fluent_i18n::t;
4
5#[derive(Debug, thiserror::Error)]
7pub enum Error {
8 #[error("{msg}", msg = t!("error-io-path", { "context" => context, "path" => path }))]
10 IoPath {
11 path: PathBuf,
13 context: &'static str,
17 source: std::io::Error,
19 },
20
21 #[error("{msg}", msg = t!("error-not-a-directory", { "path" => path }))]
23 NotADirectory {
24 path: PathBuf,
26 },
27
28 #[error("{msg}", msg = t!("error-non-absolute-paths", {
30 "paths" => paths.iter().fold(
31 String::new(),
32 |mut output, path| {
33 output.push_str(&format!("{path:?}\n"));
34 output
35 }
36 )
37 }))]
38 NonAbsolutePaths {
39 paths: Vec<PathBuf>,
41 },
42
43 #[error("{msg}", msg = t!("error-non-relative-paths", {
45 "paths" => paths.iter().fold(
46 String::new(),
47 |mut output, path| {
48 output.push_str(&format!("{path:?}\n"));
49 output
50 }
51 )
52 }))]
53 NonRelativePaths {
54 paths: Vec<PathBuf>,
56 },
57
58 #[error("{msg}\n{source}", msg = t!("error-path-strip-prefix", {
60 "prefix" => prefix,
61 "path" => path
62 }))]
63 PathStripPrefix {
64 prefix: PathBuf,
66 path: PathBuf,
68 source: StripPrefixError,
70 },
71}