use thiserror::Error;
#[derive(Debug, Clone, PartialEq, Eq, Error)]
#[non_exhaustive]
pub enum ConfigError {
#[error("Target must be specified")]
MissingTarget,
#[error("start_ttl must be at least 1")]
InvalidStartTtl,
#[error("max_hops ({max_hops}) must be greater than or equal to start_ttl ({start_ttl})")]
MaxHopsLessThanStartTtl {
start_ttl: u8,
max_hops: u8,
},
#[error("probe_timeout must be greater than 0")]
ZeroProbeTimeout,
#[error("queries_per_hop must be at least 1")]
ZeroQueriesPerHop,
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum TracerouteError {
#[error("Insufficient permissions: {required}")]
InsufficientPermissions {
required: String,
suggestion: String,
},
#[error("Failed to create socket: {0}")]
SocketError(String),
#[error("Failed to resolve host: {0}")]
ResolutionError(String),
#[error("{feature} is not yet implemented")]
NotImplemented {
feature: String,
},
#[error("IPv6 targets are not yet supported")]
Ipv6NotSupported,
#[error("Invalid configuration: {0}")]
ConfigError(#[from] ConfigError),
#[error("Failed to send probe: {0}")]
ProbeSendError(String),
#[error("{0}")]
Other(String),
}