Skip to main content

Module error

Module error 

Source
Expand description

Typed JSON-RPC error returned by super::router::MethodHandler impls.

Why: handlers need a lightweight, typed way to signal a specific JSON-RPC error code (invalid params, internal error, …) without the router having to string-sniff an anyhow::Error. Centralising the constructors here means every handler produces spec-correct codes by construction. What: RpcError { code, message, data } plus constructors for the standard JSON-RPC 2.0 codes a handler is expected to return itself, and (#2054) the vision spec’s domain error taxonomy (§13.2) — an additive layer of application-specific codes carried in the same envelope, each tagged with data.error_type so clients can match on a stable string rather than a numeric code alone. -32601 Method not found and -32600 Invalid Request are produced by super::router::Router before a handler is ever invoked, so they are intentionally not exposed as constructors here — a handler has no legitimate reason to fabricate either. Test: this module’s unit tests.

Structs§

RpcError
A JSON-RPC 2.0 error, as returned by a method handler.