ez_rust_discovery/
error.rs1use std::io;
2use std::net::AddrParseError;
3use std::num::ParseIntError;
4
5pub type Result<T, E = Error> = std::result::Result<T, E>;
7
8#[derive(Debug, thiserror::Error)]
10#[non_exhaustive]
11pub enum Error {
12 #[error("I/O error: {0}")]
14 Io(#[from] io::Error),
15
16 #[error("missing or invalid environment variable `{name}`: {source}")]
18 Env {
19 name: String,
21 #[source]
23 source: std::env::VarError,
24 },
25
26 #[error("invalid socket address: {0}")]
28 AddrParse(#[from] AddrParseError),
29
30 #[error("invalid port number: {0}")]
32 PortParse(#[from] ParseIntError),
33
34 #[error("failed to detect local IP: {0}")]
36 LocalIp(#[from] local_ip_address::Error),
37
38 #[error("nacos error: {0}")]
40 Nacos(#[from] nacos_sdk::api::error::Error),
41
42 #[error("invalid configuration: {0}")]
44 InvalidConfig(String),
45}
46
47impl Error {
48 pub(crate) fn invalid_config(msg: impl Into<String>) -> Self {
50 Self::InvalidConfig(msg.into())
51 }
52}