Skip to main content

minecraft_pinger/
error.rs

1use std::string::FromUtf8Error;
2use hickory_resolver::net::NetError;
3use thiserror::Error;
4use tokio::time::error::Elapsed;
5
6#[derive(Debug, Error)]
7pub enum PingError {
8    #[error("I/O error: {0}")]
9    Io(#[from] std::io::Error),
10
11    #[error("Global ping timeout for {0}")]
12    Timeout(#[from] Elapsed),
13
14    #[error("Connection refused")]
15    ConnectionRefused,
16    
17    #[error("Failed to send packet")]
18    SendPacket,
19    
20    #[error("Failed to read packet: {0}")]
21    ReadPacket(String),
22    
23    #[error("Invalid UTF-8: {0}")]
24    Utf8Error(#[from] FromUtf8Error),
25    
26    #[error("Serialization error: {0}")]
27    Serialization(#[from] serde_json::Error),
28    
29    #[error("DNS parse error: {0}")]
30    DnsParse(#[source] NetError),
31    
32    #[error("DNS IP not found")]
33    DnsIpNotFound,
34    
35    #[error("Address parse error: {0}")]
36    AddressParse(#[source] NetError),
37    
38    #[error("Failed to parse response")]
39    ParseResponse,
40
41    #[error("Initialization error: {0}")]
42    Init(String),
43
44    #[error("Endpoint blocked by IP filter: {0}")]
45    BlockedEndpoint(String),
46}