alpm_lint_config/error.rs
1use std::path::PathBuf;
2
3/// Errors that can occur when using alpm-lint-config.
4#[derive(Debug, thiserror::Error)]
5#[non_exhaustive]
6pub enum Error {
7 /// IO error
8 #[error("I/O error while {context}:\n{source}")]
9 Io {
10 /// The context in which the error occurred.
11 ///
12 /// This is meant to complete the sentence "I/O error while ...".
13 context: &'static str,
14 /// The error source.
15 source: std::io::Error,
16 },
17
18 /// IO error with additional path info for more context.
19 #[error("I/O error at path {path:?} while {context}:\n{source}")]
20 IoPath {
21 /// The path at which the error occurred.
22 path: PathBuf,
23 /// The context in which the error occurred.
24 ///
25 /// This is meant to complete the sentence "I/O error at path $path while ...".
26 context: &'static str,
27 /// The error source
28 source: std::io::Error,
29 },
30
31 /// TOML de/serialization error
32 #[error("Failed to deserialize configuration: {0}")]
33 Deserialization(#[from] toml::de::Error),
34}