zebra_rpc::server::error

Trait MapError

Source
pub(crate) trait MapError<T>: Sized {
    // Required methods
    fn map_error(
        self,
        code: impl Into<ErrorCode>,
    ) -> Result<T, ErrorObjectOwned>;
    fn map_error_with_prefix(
        self,
        code: impl Into<ErrorCode>,
        msg_prefix: impl ToString,
    ) -> Result<T, ErrorObjectOwned>;

    // Provided method
    fn map_misc_error(self) -> Result<T, ErrorObjectOwned> { ... }
}
Expand description

A trait for mapping errors to [jsonrpsee_types::ErrorObjectOwned].

Required Methods§

Source

fn map_error(self, code: impl Into<ErrorCode>) -> Result<T, ErrorObjectOwned>

Maps errors to [jsonrpsee_types::ErrorObjectOwned] with a specific error code.

Source

fn map_error_with_prefix( self, code: impl Into<ErrorCode>, msg_prefix: impl ToString, ) -> Result<T, ErrorObjectOwned>

Maps errors to [jsonrpsee_types::ErrorObjectOwned] with a prefixed message and a specific error code.

Provided Methods§

Source

fn map_misc_error(self) -> Result<T, ErrorObjectOwned>

Maps errors to [jsonrpsee_types::ErrorObjectOwned] with a LegacyCode::Misc error code.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T, E> MapError<T> for Result<T, E>
where E: ToString,

Source§

fn map_error(self, code: impl Into<ErrorCode>) -> Result<T, ErrorObjectOwned>

Source§

fn map_error_with_prefix( self, code: impl Into<ErrorCode>, msg_prefix: impl ToString, ) -> Result<T, ErrorObjectOwned>

Implementors§