Skip to main content

rpc_api/
error.rs

1//! RPC error types.
2
3/// Errors that can occur while preparing or performing RPC calls.
4///
5/// Protocol errors correspond to ONC-RPC reply statuses. Local transport and
6/// pool errors have no wire-level equivalent; if returned by a server handler,
7/// `rpc_driver` encodes them as [`RpcError::SystemError`].
8///
9/// # Wire boundary versus driver-local variants
10///
11/// The wire-level contract — stable across driver releases — is:
12/// [`InvalidProcedure`](RpcError::InvalidProcedure),
13/// [`ProgUnavail`](RpcError::ProgUnavail),
14/// [`InvalidVersion`](RpcError::InvalidVersion),
15/// [`RpcMismatch`](RpcError::RpcMismatch),
16/// [`GarbageArguments`](RpcError::GarbageArguments),
17/// [`SystemError`](RpcError::SystemError), and
18/// [`AuthenticationError`](RpcError::AuthenticationError).
19///
20/// The remaining variants describe local operational failures
21/// (connections, pools) and are surfaced to callers without crossing the
22/// wire. The enum is `#[non_exhaustive]`, so new operational variants can
23/// be added without a breaking release; any variant unknown to a given
24/// driver release is encoded on the wire as a system error.
25#[non_exhaustive]
26#[derive(Debug, thiserror::Error, PartialEq, Eq)]
27pub enum RpcError {
28    /// The requested procedure is not defined for the selected service.
29    #[error("Invalid procedure")]
30    InvalidProcedure,
31    /// No service is registered for the requested program number.
32    #[error("Program unavailable")]
33    ProgUnavail,
34    /// The program exists, but not at the requested version.
35    #[error("Invalid version: low {low}, high {high}")]
36    InvalidVersion {
37        /// Lowest supported version.
38        low: u32,
39        /// Highest supported version.
40        high: u32,
41    },
42    /// The peer requested an unsupported ONC-RPC protocol version.
43    #[error("Rpc Mismatch")]
44    RpcMismatch,
45    /// The call arguments could not be decoded.
46    #[error("Garbage arguments")]
47    GarbageArguments,
48    /// The call failed without a more specific wire-level error.
49    #[error("System error")]
50    SystemError,
51    /// Authentication credentials or verification failed.
52    #[error("Authentication error")]
53    AuthenticationError,
54    /// A client connection could not be established.
55    #[error("Connection failed")]
56    ConnectFailed,
57    /// The connection pool has been shut down or can no longer accept work.
58    #[error("Connection pool closed")]
59    PoolClosed,
60    /// The pool abandoned a queued request before it could complete.
61    #[error("Request canceled")]
62    Canceled,
63    /// The requested pool configuration is invalid.
64    #[error("Invalid pool configuration")]
65    InvalidPoolConfiguration,
66}