voa_config/error.rs
1//! Error handling for VOA configuration files.
2
3use std::path::PathBuf;
4
5/// The error that can occur when using VOA configuration files.
6#[derive(Debug, thiserror::Error)]
7pub enum Error {
8 /// There are no context settings.
9 #[error("There must be at least one context settings")]
10 ContextSettingsMissing,
11
12 /// An I/O error occurred at a path.
13 #[error("I/O error at path {path} while {context}:\n{source}")]
14 IoPath {
15 /// The path at which the error occurred.
16 path: PathBuf,
17 /// The context in which the error occurred.
18 ///
19 /// This is meant to complete the sentence "I/O error at path while ".
20 context: &'static str,
21 /// The error source.
22 source: std::io::Error,
23 },
24
25 /// An OpenPGP technology error occurred.
26 #[error(transparent)]
27 OpenpgpTechnology(#[from] crate::config::technology::openpgp::Error),
28
29 /// An error occurred while deserializing an object as a YAML string.
30 #[error("YAML deserialization error while {context}:\n{source}")]
31 YamlDeserialize {
32 /// The context in which the error occurred.
33 ///
34 /// This is meant to complete the sentence "YAML deserialization error while ".
35 context: String,
36 /// The error source.
37 source: serde_saphyr::Error,
38 },
39
40 /// An error occurred while serializing an object as a YAML string.
41 #[error("YAML serialization error while {context}:\n{source}")]
42 YamlSerialize {
43 /// The context in which the error occurred.
44 ///
45 /// This is meant to complete the sentence "YAML serialization error while ".
46 context: &'static str,
47 /// The error source.
48 source: serde_saphyr::ser_error::Error,
49 },
50
51 /// A garde validation error occurred.
52 #[error("Validation error while {context}: {source}")]
53 Validation {
54 /// The context in which the error occurred.
55 ///
56 /// This is meant to complete the sentence "Validation error while ".
57 context: String,
58
59 /// The error source.
60 source: garde::Report,
61 },
62
63 /// A [`voa_core::Error`] occurred.
64 #[error(transparent)]
65 VoaCore(#[from] voa_core::Error),
66}