/ src / error.rs
error.rs
 1  // SPDX-License-Identifier: MIT
 2  // Copyright (c) 2025 kingananas20
 3  
 4  use crate::config_loader::ParseFileFormatError;
 5  
 6  /// Error type used in the crate
 7  #[derive(Debug, thiserror::Error)]
 8  pub enum Error {
 9      /// Io error
10      #[error("IO error: {0}")]
11      Io(#[from] std::io::Error),
12  
13      /// Serde error
14      #[error("Serialization error: {0:?}")]
15      Serde(#[from] serde_json::Error),
16  
17      /// Toml error
18      #[error("TOML error: {0}")]
19      Toml(#[from] toml::de::Error),
20  
21      /// Yaml error
22      #[error("YAML error: {0}")]
23      Yaml(#[from] serde_yaml::Error),
24  
25      /// Parse file format error
26      #[error("Parse file format error")]
27      ParseFileFormat(#[from] ParseFileFormatError),
28  
29      /// Error if parsing fails because of missing fields
30      #[error("Config parsing error for type {type_name}: {source:?}")]
31      ConfigParse {
32          /// Name of the type
33          type_name: &'static str,
34          /// Source of the error
35          #[source]
36          source: serde_json::Error,
37      },
38  
39      /// Environment error
40      #[error("Environment error: {0}")]
41      Environment(String),
42  
43      /// Validation error
44      #[error("Validation error: {0}")]
45      Validation(String),
46  }