Trait RespError

Source
pub trait RespError {
    type ExtraMessage: Serialize + 'static + Sized + Display;

    // Required methods
    fn log_message(&self) -> Cow<'_, str>;
    fn extra_message(&self) -> Self::ExtraMessage;

    // Provided methods
    fn resp_message(&self) -> Cow<'_, str> { ... }
    fn http_code(&self) -> StatusCode { ... }
    fn resp_message_default() -> Option<Cow<'static, str>> { ... }
    fn extra_message_default() -> Option<Self::ExtraMessage> { ... }
}
Expand description

the error when RespResult is Err(_)

Required Associated Types§

Source

type ExtraMessage: Serialize + 'static + Sized + Display

the associate type of extra message

Required Methods§

Source

fn log_message(&self) -> Cow<'_, str>

message for logger

Source

fn extra_message(&self) -> Self::ExtraMessage

get the extra message

Provided Methods§

Source

fn resp_message(&self) -> Cow<'_, str>

message for response

§Default

the RespError::resp_message default is equal to RespError::log_message

Source

fn http_code(&self) -> StatusCode

the http code of this error

§Default

the default http code is 500 Internal Server Error

Source

fn resp_message_default() -> Option<Cow<'static, str>>

when fix-field = true using this value serialize error message

§Default

default is None, it will serialize to null

Source

fn extra_message_default() -> Option<Self::ExtraMessage>

when fix-field = true using this value serialize extra error message

§Default

default is None, it will be serialized to null

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.

Implementors§