tor-error: Add ErrorKinds for RPC errors.

These are experimental for now so that we can change them without
breaking semver.
This commit is contained in:
Nick Mathewson 2023-04-12 13:30:24 -04:00
parent 2e017d3575
commit e37b017342
2 changed files with 25 additions and 1 deletions

View File

@ -13,7 +13,8 @@ categories = ["rust-patterns"]
[features]
default = ["backtrace"]
experimental-api = []
experimental-api = ["rpc"]
rpc = []
[dependencies]
backtrace = { version = "0.3.39", optional = true }

View File

@ -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