Trait manyhow::ResultExt

source ·
pub trait ResultExt<T, E>: Sized {
    // Required methods
    fn context_with<C: ToTokensError + 'static>(
        self,
        error: impl FnOnce() -> C
    ) -> Result<T, Error>;
    fn attachment(self, label: &'static str, msg: impl Display) -> Self
       where E: Attachment;

    // Provided methods
    fn context(self, error: impl ToTokensError + 'static) -> Result<T, Error> { ... }
    fn error(self, msg: impl Display) -> Self
       where E: Attachment { ... }
    fn warning(self, msg: impl Display) -> Self
       where E: Attachment { ... }
    fn note(self, msg: impl Display) -> Self
       where E: Attachment { ... }
    fn help(self, msg: impl Display) -> Self
       where E: Attachment { ... }
}
Expand description

Required Methods§

source

fn context_with<C: ToTokensError + 'static>( self, error: impl FnOnce() -> C ) -> Result<T, Error>

If self is error, attaches another error, closure is only executed if the Result is Err

source

fn attachment(self, label: &'static str, msg: impl Display) -> Self
where E: Attachment,

If self is error, extend error message

Only works if E implements Attachment which is the case for ErrorMessage

Provided Methods§

source

fn context(self, error: impl ToTokensError + 'static) -> Result<T, Error>

If self is error, attaches another error

source

fn error(self, msg: impl Display) -> Self
where E: Attachment,

Attaches a new error message to self reusing the same span

source

fn warning(self, msg: impl Display) -> Self
where E: Attachment,

Attaches a new warning message to self reusing the same span

source

fn note(self, msg: impl Display) -> Self
where E: Attachment,

Attaches a new note message to self reusing the same span

source

fn help(self, msg: impl Display) -> Self
where E: Attachment,

Attaches a new help message to self reusing the same span

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T, E: ToTokensError + 'static> ResultExt<T, E> for Result<T, E>