Skip to main content

IntoErrorCode

Trait IntoErrorCode 

Source
pub trait IntoErrorCode {
    // Required methods
    fn error_code(&self) -> ErrorCode;
    fn message(&self) -> String;

    // Provided method
    fn jsonrpc_code(&self) -> i32 { ... }
}
Expand description

Trait for converting errors to protocol-agnostic error codes.

Implement this for your error types, or use the derive macro.

Required Methods§

Source

fn error_code(&self) -> ErrorCode

Get the error code for this error

Source

fn message(&self) -> String

Get a human-readable message

Provided Methods§

Source

fn jsonrpc_code(&self) -> i32

Get the JSON-RPC numeric error code for this error.

Defaults to the code derived from error_code(). Override this for per-variant JSON-RPC codes (e.g. -32602 for invalid params).

Implementations on Foreign Types§

Source§

impl IntoErrorCode for &str

Source§

impl IntoErrorCode for Box<dyn Error + Send + Sync>

Source§

impl IntoErrorCode for Box<dyn Error>

Source§

impl IntoErrorCode for String

Source§

impl IntoErrorCode for Error

Implementors§