Expand description
Error types for the rust-mc-status library.
§Hierarchy
McError is the top-level error type. Each variant wraps a sub-error
that categorises the failure more precisely:
McError
├── Network(NetworkError) — DNS lookup, TCP/UDP connect, timeout
├── Protocol(ProtocolError) — malformed packets, JSON, UTF-8, Base64
├── Config(ConfigError) — bad address string, invalid port, unknown edition
├── Io(std::io::Error) — OS-level I/O (file write, socket error)
└── Proxy(ProxyError) — SOCKS5/HTTP proxy failures [feature = "proxy"]§Matching
Match at the top level for broad handling, or pattern-match into sub-errors for fine-grained control:
use rust_mc_status::{McClient, McError, StatusExt};
use rust_mc_status::error::{NetworkError, ProtocolError, ConfigError};
let client = McClient::builder().build();
match client.java("mc.hypixel.net").await {
Ok(s) => println!("online: {}", s.display_players()),
// Broad match — catches any network failure
Err(McError::Network(e)) => println!("network: {e}"),
// Specific match — only DNS failures
Err(McError::Network(NetworkError::Dns(msg))) => println!("DNS: {msg}"),
// Config errors are always the caller's fault
Err(McError::Config(ConfigError::InvalidPort(p))) => println!("bad port: {p}"),
Err(e) => println!("other: {e}"),
}§Retry guidance
| Variant | Retryable? |
|---|---|
Network::Timeout | Yes — server may be temporarily overloaded |
Network::Connection | Yes — transient network hiccup |
Network::Dns | No — unlikely to resolve immediately |
Protocol::* | No — same response on retry |
Config::* | No — fix the input |
Proxy::* | No — fix proxy configuration |
Enums§
- Config
Error - Errors caused by invalid caller-provided configuration.
- McError
- Top-level error type returned by all fallible operations in this library.
- Network
Error - Errors that occur at the network layer before any Minecraft protocol is spoken.
- Protocol
Error - Errors that occur while speaking the Minecraft wire protocol.