From e37b017342249fb88c8212fa356f68cf66e57ab7 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 12 Apr 2023 13:30:24 -0400 Subject: [PATCH] tor-error: Add ErrorKinds for RPC errors. These are experimental for now so that we can change them without breaking semver. --- crates/tor-error/Cargo.toml | 3 ++- crates/tor-error/src/lib.rs | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/crates/tor-error/Cargo.toml b/crates/tor-error/Cargo.toml index 6dd18e22f..574bbc5b0 100644 --- a/crates/tor-error/Cargo.toml +++ b/crates/tor-error/Cargo.toml @@ -13,7 +13,8 @@ categories = ["rust-patterns"] [features] default = ["backtrace"] -experimental-api = [] +experimental-api = ["rpc"] +rpc = [] [dependencies] backtrace = { version = "0.3.39", optional = true } diff --git a/crates/tor-error/src/lib.rs b/crates/tor-error/src/lib.rs index f867d9684..61f97ca09 100644 --- a/crates/tor-error/src/lib.rs +++ b/crates/tor-error/src/lib.rs @@ -614,6 +614,29 @@ pub enum ErrorKind { #[display(fmt = "possible clock skew detected")] ClockSkew, + /// An RPC operation failed because a request could not be parsed or was + /// otherwise invalid. + #[display(fmt = "invalid RPC request")] + #[cfg(feature = "rpc")] + RpcInvalidRequest, + + /// An RPC operation failed because a method type could not be found, + /// or is not available on a given object. + #[display(fmt = "RPC method not found")] + #[cfg(feature = "rpc")] + RpcMethodNotFound, + + /// An RPC operation failed because the method type's parameters were not + /// correct for it. + #[display(fmt = "RPC invalid parameters")] + #[cfg(feature = "rpc")] + RpcInvalidMethodParameters, + + /// An RPC operation failed because a given object could not be found. + #[display(fmt = "RPC object not found")] + #[cfg(feature = "rpc")] + RpcObjectNotFound, + /// Internal error (bug) in Arti. /// /// A supposedly impossible problem has arisen. This indicates a bug in