This repository has been archived on 2024-07-25. You can view files and clone it, but cannot push or open issues or pull requests.
enve/itconfig/src/error.rs

27 lines
835 B
Rust

use std::error;
use std::fmt;
/// The error type for operations interacting with environment variables
#[derive(Debug, PartialEq)]
pub enum EnvError {
/// The specified environment variable was not present in the current process's environment.
MissingVariable(String),
/// Failed to parse the specified environment variable.
FailedToParse(String),
}
impl fmt::Display for EnvError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self {
EnvError::MissingVariable(env_name) => {
write!(f, r#"Environment variable "{}" is missing"#, env_name)
}
EnvError::FailedToParse(env_name) => {
write!(f, r#"Failed to parse environment variable "{}""#, env_name)
}
}
}
}
impl error::Error for EnvError {}