product_os_configuration/
error.rs1use alloc::string::String;
4use alloc::vec::Vec;
5use core::fmt;
6
7#[derive(Debug, Clone)]
9pub enum ConfigError {
10 FileReadError(String),
12 ParseError(String),
14 MissingSectionError(String),
16 ValidationError(Vec<String>),
18}
19
20impl fmt::Display for ConfigError {
21 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22 match self {
23 Self::FileReadError(msg) => write!(f, "Config file read error: {msg}"),
24 Self::ParseError(msg) => write!(f, "Config parse error: {msg}"),
25 Self::MissingSectionError(key) => write!(f, "Missing config section: {key}"),
26 Self::ValidationError(errors) => {
27 write!(f, "Config validation errors: ")?;
28 for (i, err) in errors.iter().enumerate() {
29 if i > 0 {
30 write!(f, "; ")?;
31 }
32 write!(f, "{err}")?;
33 }
34 Ok(())
35 }
36 }
37 }
38}
39
40#[cfg(feature = "std")]
41extern crate std;
42
43#[cfg(feature = "std")]
44impl std::error::Error for ConfigError {}