pub struct RpcError {
pub code: ErrorCode,
pub message: String,
pub data: ErrorData,
}Expand description
The canonical DIG-node RPC error object: {code, message, data:{code, origin}}.
Build one with RpcError::new (or the code-specific helpers) so the numeric
code, the data.code machine string, and the origin can never drift apart.
Fields§
§code: ErrorCodeThe numeric wire code.
message: StringA human-readable message. May be refined over time; data.code is the
stable branch key.
data: ErrorDataStructured, machine-branchable context.
Implementations§
Source§impl RpcError
impl RpcError
Sourcepub fn new(
code: ErrorCode,
message: impl Into<String>,
origin: ErrorOrigin,
) -> Self
pub fn new( code: ErrorCode, message: impl Into<String>, origin: ErrorOrigin, ) -> Self
The single constructor: mint the canonical envelope from a code, a
message, and an origin. data.code is derived from code so the two
can never disagree.
Sourcepub fn of(code: ErrorCode, message: impl Into<String>) -> Self
pub fn of(code: ErrorCode, message: impl Into<String>) -> Self
Mint an error using the code’s default origin.
Sourcepub fn code_only(code: ErrorCode) -> Self
pub fn code_only(code: ErrorCode) -> Self
Mint an error using both the code’s default origin and its default message.
Sourcepub fn with_redirect(self, redirect: RedirectInfo) -> Self
pub fn with_redirect(self, redirect: RedirectInfo) -> Self
Attach a RedirectInfo payload (for
ContentRedirect).
Sourcepub fn with_extra(self, key: impl Into<String>, value: Value) -> Self
pub fn with_extra(self, key: impl Into<String>, value: Value) -> Self
Attach one extra data field (flattened onto data).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for RpcError
impl<'de> Deserialize<'de> for RpcError
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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()