Trait app_frame::error::LogError

source ·
pub trait LogError<T>: Sized {
    // Required methods
    fn log_as(self, level: Level) -> Option<T>;
    fn log_with_context_as<Ctx: Fn() -> String>(
        self,
        level: Level,
        ctx: Ctx
    ) -> Option<T>;
    fn log_as_passthrough(self, level: Level) -> Self;
    fn log_with_context_as_passthrough<Ctx: Fn() -> String>(
        self,
        level: Level,
        ctx: Ctx
    ) -> Self;

    // Provided methods
    fn log(self) -> Option<T> { ... }
    fn log_context(self, ctx: &str) -> Option<T> { ... }
    fn log_with_context<Ctx: Fn() -> String>(self, ctx: Ctx) -> Option<T> { ... }
    fn log_context_as(self, level: Level, ctx: &str) -> Option<T> { ... }
    fn log_passthrough(self) -> Self { ... }
    fn log_context_passthrough(self, ctx: &str) -> Self { ... }
    fn log_with_context_passthrough<Ctx: Fn() -> String>(self, ctx: Ctx) -> Self { ... }
    fn log_context_as_passthrough(self, level: Level, ctx: &str) -> Self { ... }
}
Expand description

Enables logging of errors, to move forward without returning the error.

Required Methods§

source

fn log_as(self, level: Level) -> Option<T>

Logs if there was an error and converts the result into an option

source

fn log_with_context_as<Ctx: Fn() -> String>( self, level: Level, ctx: Ctx ) -> Option<T>

Lazily logs if there was an error with a message at the provided log level, and converts the result into an option

source

fn log_as_passthrough(self, level: Level) -> Self

Logs if there was an error and returns the result unchanged

source

fn log_with_context_as_passthrough<Ctx: Fn() -> String>( self, level: Level, ctx: Ctx ) -> Self

Lazily logs if there was an error with a message at the provided log level, and returns the result unchanged

Provided Methods§

source

fn log(self) -> Option<T>

Logs if there was an error and converts the result into an option

source

fn log_context(self, ctx: &str) -> Option<T>

Logs if there was an error with a message and converts the result into an option

source

fn log_with_context<Ctx: Fn() -> String>(self, ctx: Ctx) -> Option<T>

Lazily logs if there was an error with a message and converts the result into an option

source

fn log_context_as(self, level: Level, ctx: &str) -> Option<T>

Logs if there was an error with a message at the provided log level, and converts the result into an option

source

fn log_passthrough(self) -> Self

Logs if there was an error and returns the result unchanged

source

fn log_context_passthrough(self, ctx: &str) -> Self

Logs if there was an error with a message and returns the result unchanged

source

fn log_with_context_passthrough<Ctx: Fn() -> String>(self, ctx: Ctx) -> Self

Lazily logs if there was an error with a message and returns the result unchanged

source

fn log_context_as_passthrough(self, level: Level, ctx: &str) -> Self

Logs if there was an error with a message at the provided log level, and returns the result unchanged

Implementations on Foreign Types§

source§

impl<T, E: Display + 'static> LogError<T> for Result<T, E>

source§

fn log_as(self, level: Level) -> Option<T>

source§

fn log_with_context_as<Ctx: Fn() -> String>( self, level: Level, ctx: Ctx ) -> Option<T>

source§

fn log_as_passthrough(self, level: Level) -> Self

source§

fn log_with_context_as_passthrough<Ctx: Fn() -> String>( self, level: Level, ctx: Ctx ) -> Self

Implementors§