Skip to main content

mc_status_probe/
error.rs

1use thiserror::Error;
2
3/// Errors that can occur during a Minecraft server ping.
4#[derive(Error, Debug)]
5pub enum PingError {
6    /// TCP connection failed or timed out.
7    #[error("connection failed: {0}")]
8    Connection(std::io::Error),
9
10    /// Connection timed out before handshake could complete.
11    #[error("connection timed out")]
12    Timeout,
13
14    /// Received invalid or malformed data from the server.
15    #[error("protocol error: {0}")]
16    Protocol(String),
17
18    /// Failed to parse the JSON response from the server.
19    #[error("JSON parse error: {0}")]
20    Json(#[from] serde_json::Error),
21
22    /// The server returned a response with unexpected structure.
23    #[error("unexpected response: {0}")]
24    UnexpectedResponse(String),
25}