dig_rpc/error.rs
1//! Server operational errors (bind / TLS / fatal).
2//!
3//! These are the server's own lifecycle failures — distinct from the per-request
4//! [`RpcError`](dig_rpc_protocol::RpcError) carried in the JSON-RPC envelope. A
5//! `RpcServerError` means the server could not start or keep running.
6
7use std::net::SocketAddr;
8use std::sync::Arc;
9
10/// A server lifecycle error.
11#[derive(Debug, Clone, thiserror::Error)]
12pub enum RpcServerError {
13 /// Binding the listen socket failed.
14 #[error("failed to bind {addr}: {source}")]
15 BindFailed {
16 /// The address that could not be bound.
17 addr: SocketAddr,
18 /// The underlying I/O error.
19 source: Arc<std::io::Error>,
20 },
21
22 /// Loading or building the TLS configuration failed.
23 #[error("TLS configuration error: {0}")]
24 Tls(Arc<anyhow::Error>),
25
26 /// The server terminated with a fatal error.
27 #[error("fatal server error: {0}")]
28 Fatal(Arc<anyhow::Error>),
29}