alpm_lint_config/error.rs
1use std::path::PathBuf;
2
3use fluent_i18n::t;
4
5/// Errors that can occur when using alpm-lint-config.
6#[derive(Debug, thiserror::Error)]
7#[non_exhaustive]
8pub enum Error {
9 /// IO error
10 #[error("{msg}", msg = t!("error-io", {
11 "context" => context,
12 "source" => source.to_string()
13 }))]
14 Io {
15 /// The context in which the error occurred.
16 ///
17 /// This is meant to complete the sentence "I/O error while ...".
18 context: String,
19 /// The error source.
20 source: std::io::Error,
21 },
22
23 /// IO error with additional path info for more context.
24 #[error("{msg}", msg = t!("error-io-path", {
25 "path" => path.display().to_string(),
26 "context" => context,
27 "source" => source.to_string()
28 }))]
29 IoPath {
30 /// The path at which the error occurred.
31 path: PathBuf,
32 /// The context in which the error occurred.
33 ///
34 /// This is meant to complete the sentence "I/O error at path $path while ...".
35 context: String,
36 /// The error source
37 source: std::io::Error,
38 },
39
40 /// TOML de/serialization error
41 #[error("{msg}", msg = t!("error-toml-deserialization", { "source" => .0.to_string() }))]
42 Deserialization(#[from] toml::de::Error),
43}