use std::io;
use std::net::AddrParseError;
use std::num::ParseIntError;
pub type Result<T, E = Error> = std::result::Result<T, E>;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error("I/O error: {0}")]
Io(#[from] io::Error),
#[error("missing or invalid environment variable `{name}`: {source}")]
Env {
name: String,
#[source]
source: std::env::VarError,
},
#[error("invalid socket address: {0}")]
AddrParse(#[from] AddrParseError),
#[error("invalid port number: {0}")]
PortParse(#[from] ParseIntError),
#[error("failed to detect local IP: {0}")]
LocalIp(#[from] local_ip_address::Error),
#[error("nacos error: {0}")]
Nacos(#[from] nacos_sdk::api::error::Error),
#[error("invalid configuration: {0}")]
InvalidConfig(String),
}
impl Error {
pub(crate) fn invalid_config(msg: impl Into<String>) -> Self {
Self::InvalidConfig(msg.into())
}
}