Skip to main content

signet_constants/types/
error.rs

1/// Captures errors related to loading configuration from the environment or other sources.
2#[derive(Debug, thiserror::Error)]
3pub enum ConfigError {
4    /// Missing `signetConstants` genesis field.
5    #[error("missing signetConstants field in genesis")]
6    MissingGenesis(&'static str),
7    /// Error loading from environment variable
8    #[error("missing or non-unicode environment variable: {0}")]
9    Var(String),
10    /// Error parsing environment variable
11    #[error("failed to parse environment variable: {0}")]
12    Parse(#[from] std::num::ParseIntError),
13    /// Error parsing boolean environment variable
14    #[error("failed to parse boolean environment variable")]
15    ParseBool,
16    /// Error parsing hex from environment variable
17    #[error("failed to parse hex: {0}")]
18    Hex(#[from] alloy::hex::FromHexError),
19    /// Error parsing JSON
20    #[error("failed to parse JSON: {0}")]
21    Json(#[from] serde_json::Error),
22    /// Error reading file
23    #[error("failed to read file: {0}")]
24    Io(#[from] std::io::Error),
25}
26
27impl ConfigError {
28    /// Missing or non-unicode env var.
29    pub fn missing(s: &str) -> Self {
30        ConfigError::Var(s.to_string())
31    }
32}