pub enum RouteError<'a> {
Decode(DecodeError),
BatchNotAllowed,
MethodNotFound(Method<'a>),
InvalidParams {
method: Method<'a>,
reason: &'static str,
},
}Expand description
Why a frame was refused.
§Why the method name is borrowed
The name is borrowed from the frame rather than interned, because a table
of “known” names is a second list that can disagree with the method table,
and a disagreement here is silent: a legitimate method name that the intern
list has not heard of would be reported to the operator as unknown, which
is exactly the case an operator most needs to see. The frame outlives the
error — the error is produced while reading it — so the borrow is free.
Variants§
Decode(DecodeError)
The frame was not decodable at all.
BatchNotAllowed
A batch arrived and this session does not accept one (-32600).
InvalidRequest rather than a code of its own: the specification has no
batch-specific code, and inventing one would make a peer that switches
on codes meet something it has never heard of.
MethodNotFound(Method<'a>)
The method is not in this protocol’s table (-32601).
InvalidParams
The params did not fit the method (-32602).
Implementations§
Source§impl RouteError<'_>
impl RouteError<'_>
Sourcepub const fn code(&self) -> IrErrorCode
pub const fn code(&self) -> IrErrorCode
The JSON-RPC code this failure is reported as.
The batch case answers InvalidRequest and the unknown-method case
answers MethodNotFound; both are the codes the specification gives,
and reporting a batch refusal as -32601 would tell the peer the wrong
thing about which half of the problem to fix.
Trait Implementations§
Source§impl<'a> Clone for RouteError<'a>
impl<'a> Clone for RouteError<'a>
Source§impl<'a> Debug for RouteError<'a>
impl<'a> Debug for RouteError<'a>
Source§impl<'a> Display for RouteError<'a>
impl<'a> Display for RouteError<'a>
impl<'a> Eq for RouteError<'a>
Source§impl<'a> Error for RouteError<'a>
impl<'a> Error for RouteError<'a>
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()