1use std::{collections::HashSet, path::PathBuf, string::FromUtf8Error};
2
3#[cfg(doc)]
4use crate::Mtree;
5use crate::mtree::path_validation_error::PathValidationErrors;
6
7#[derive(Debug, thiserror::Error)]
9#[non_exhaustive]
10pub enum Error {
11 #[error(transparent)]
13 AlpmCommon(#[from] alpm_common::Error),
14
15 #[error("The following file system paths are duplicates:\n{}",
17 paths.iter().fold(String::new(), |mut output, path| {
18 output.push_str(&format!("{path:?}\n"));
19 output
20 })
21 )]
22 DuplicatePaths {
23 paths: HashSet<PathBuf>,
25 },
26
27 #[cfg(feature = "creation")]
29 #[error("File creation error:\n{0}")]
30 File(#[from] crate::CreationError),
31
32 #[error("I/O error while {0}:\n{1}")]
34 Io(&'static str, std::io::Error),
35
36 #[error("I/O error at path {0:?} while {1}:\n{2}")]
38 IoPath(PathBuf, &'static str, std::io::Error),
39
40 #[error(transparent)]
42 InvalidUTF8(#[from] FromUtf8Error),
43
44 #[error("No input file given.")]
46 NoInputFile,
47
48 #[error("Error while unpacking gzip file:\n{0}")]
50 InvalidGzip(std::io::Error),
51
52 #[error(transparent)]
54 PathValidation(#[from] PathValidationErrors),
55
56 #[error("File parsing error:\n{0}")]
58 ParseError(String),
59
60 #[error("Error while interpreting file in line {0}:\nAffected line:\n{1}\n\nReason:\n{2}")]
62 InterpreterError(usize, String, String),
63
64 #[error("JSON error: {0}")]
66 Json(#[from] serde_json::Error),
67
68 #[error("Unsupported schema version: {0}")]
70 UnsupportedSchemaVersion(String),
71}