Trait mz_ore::error::ErrorExt

source ·
pub trait ErrorExt: Error {
    // Provided methods
    fn display_with_causes(&self) -> ErrorChainFormatter<&Self> { ... }
    fn to_string_with_causes(&self) -> String { ... }
}
Expand description

Extension methods for std::error::Error.

Provided Methods§

source

fn display_with_causes(&self) -> ErrorChainFormatter<&Self>

Returns a type that displays the error, along with the chain of source errors or causes, if there are any.

§Examples
use anyhow::anyhow;
use mz_ore::error::ErrorExt;

let error = anyhow!("inner");
let error = error.context("context");
assert_eq!(format!("error: ({})", error.display_with_causes()), "error: (context: inner)");
source

fn to_string_with_causes(&self) -> String

Converts self to a string String, along with the chain of source errors or causes, if there are any.

§Examples

Basic usage:

use anyhow::anyhow;
use mz_ore::error::ErrorExt;

let error = anyhow!("inner");
let error = error.context("context");
assert_eq!(error.to_string_with_causes(), "context: inner");

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<E: Error + ?Sized> ErrorExt for E