Skip to main content

ErrorPrinter

Trait ErrorPrinter 

Source
pub trait ErrorPrinter {
    // Required methods
    fn log_error<M: Display>(self, message: M) -> Self;
    fn log_error_fn<M: Display, F: FnOnce() -> M>(self, message_fn: F) -> Self;
    fn warn_error<M: Display>(self, message: M) -> Self;
    fn warn_error_fn<M: Display, F: FnOnce() -> M>(self, message_fn: F) -> Self;
    fn debug_error<M: Display>(self, message: M) -> Self;
    fn debug_error_fn<M: Display, F: FnOnce() -> M>(self, message_fn: F) -> Self;
    fn info_error<M: Display>(self, message: M) -> Self;
    fn info_error_fn<M: Display, F: FnOnce() -> M>(self, message_fn: F) -> Self;
}
Expand description

A helper trait to log errors. The logging functions will track the caller’s callsite. For a chain of calls A -> B -> C -> ErrorPrinter, the topmost function without #[track_caller] is deemed the callsite.

Required Methods§

Source

fn log_error<M: Display>(self, message: M) -> Self

Source

fn log_error_fn<M: Display, F: FnOnce() -> M>(self, message_fn: F) -> Self

Source

fn warn_error<M: Display>(self, message: M) -> Self

Source

fn warn_error_fn<M: Display, F: FnOnce() -> M>(self, message_fn: F) -> Self

Source

fn debug_error<M: Display>(self, message: M) -> Self

Source

fn debug_error_fn<M: Display, F: FnOnce() -> M>(self, message_fn: F) -> Self

Source

fn info_error<M: Display>(self, message: M) -> Self

Source

fn info_error_fn<M: Display, F: FnOnce() -> M>(self, message_fn: F) -> Self

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: Debug> ErrorPrinter for Result<T, E>

Source§

fn log_error<M: Display>(self, message: M) -> Self

If self is an Err(e), prints out the given string to tracing::error, appending “error: {e}” to the end of the message.

Source§

fn log_error_fn<M: Display, F: FnOnce() -> M>(self, message_fn: F) -> Self

If self is an Err(e), calls the function to get a string to log to tracing::error, appending “error: {e}” to the end of the message.

Source§

fn warn_error<M: Display>(self, message: M) -> Self

If self is an Err(e), prints out the given string to tracing::warn, appending “error: {e}” to the end of the message.

Source§

fn warn_error_fn<M: Display, F: FnOnce() -> M>(self, message_fn: F) -> Self

If self is an Err(e), calls the function to get a string to log to tracing::warn, appending “error: {e}” to the end of the message.

Source§

fn debug_error<M: Display>(self, message: M) -> Self

If self is an Err(e), prints out the given string to tracing::debug, appending “error: {e}” to the end of the message.

Source§

fn debug_error_fn<M: Display, F: FnOnce() -> M>(self, message_fn: F) -> Self

If self is an Err(e), calls the function to get a string to log to tracing::debug, appending “error: {e}” to the end of the message.

Source§

fn info_error<M: Display>(self, message: M) -> Self

If self is an Err(e), prints out the given string to tracing::info, appending “error: {e}” to the end of the message.

Source§

fn info_error_fn<M: Display, F: FnOnce() -> M>(self, message_fn: F) -> Self

If self is an Err(e), calls the function to get a string to log to tracing::info, appending “error: {e}” to the end of the message.

Implementors§