pub struct RpcError {
pub error_type: String,
pub message: String,
pub traceback: String,
pub request_id: String,
pub auth_reason: Option<AuthReason>,
pub retry_after_seconds: Option<u32>,
}Expand description
An RPC-level error, serialized on the wire as an EXCEPTION log batch.
Fields§
§error_type: StringError category (matches Python exception class names: “ValueError”, “RuntimeError”, “TypeError”, “ProtocolError”, “VersionError”, …).
message: StringHuman-readable error message.
traceback: StringOptional stack trace or remote traceback string.
request_id: StringOptional request ID attached when the error was produced.
auth_reason: Option<AuthReason>Machine-readable reason when this error is an authentication
rejection. None means unclassified, which renders as
crate::unauthorized::AuthReason::Unauthorized — guessing a finer
code from an unclassified failure would mean matching on message
text.
retry_after_seconds: Option<u32>Retry-After hint, in seconds, carried by a transient failure —
see RpcError::auth_unavailable. None on every other error.
Implementations§
Source§impl RpcError
impl RpcError
pub fn new(error_type: impl Into<String>, message: impl Into<String>) -> Self
An authenticator could not answer. Not a rejection.
“The credential is bad” and “I could not find out whether the credential is bad” are different answers, and collapsing them is expensive in both directions. A sidecar restart surfacing as 401 makes every caller re-authenticate at once; a caller that negative-caches rejections will cache the outage and stay down after the sidecar comes back.
crate::auth::chain_authenticate propagates it — every Err from an
authenticator short-circuits the chain, so unlike the Python reference
there is no exception hierarchy to get wrong here; what the distinct
error_type buys is the HTTP mapping, which renders 503 +
Retry-After instead of 401.
Raise it for transport failures, timeouts, and 5xx from a remote authority. Never for a credential the authority answered about.
Sourcepub fn with_retry_after(self, seconds: u32) -> Self
pub fn with_retry_after(self, seconds: u32) -> Self
Override the Retry-After hint on a transient failure.
Whether this is the transient “could not determine” signal rather than a rejection.
Sourcepub fn auth_failure(reason: AuthReason, detail: impl Into<String>) -> Self
pub fn auth_failure(reason: AuthReason, detail: impl Into<String>) -> Self
Classify this error as an authentication rejection with reason.
Returned from an authenticate callback, this is what lets the 401
carry a code a client can branch on rather than the
crate::unauthorized::AuthReason::Unauthorized fallback.
pub fn value_error(msg: impl Into<String>) -> Self
pub fn runtime_error(msg: impl Into<String>) -> Self
pub fn type_error(msg: impl Into<String>) -> Self
pub fn protocol_error(msg: impl Into<String>) -> Self
pub fn version_error(msg: impl Into<String>) -> Self
pub fn permission_error(msg: impl Into<String>) -> Self
pub fn attribute_error(msg: impl Into<String>) -> Self
Sourcepub fn session_lost_error(msg: impl Into<String>) -> Self
pub fn session_lost_error(msg: impl Into<String>) -> Self
Sticky-session token did not resolve to a live registry entry
(missing, expired, evicted, wrong worker, or principal mismatch).
Mirrors Python’s vgi_rpc.rpc.SessionLostError.
Sourcepub fn server_draining_error(msg: impl Into<String>) -> Self
pub fn server_draining_error(msg: impl Into<String>) -> Self
Server is draining: new ctx.open_session calls are rejected while
existing sessions continue to serve. Mirrors Python’s
vgi_rpc.rpc.ServerDrainingError.
Trait Implementations§
Source§impl Error for RpcError
impl Error for RpcError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()