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§
sourcefn display_with_causes(&self) -> ErrorChainFormatter<&Self>
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)");
sourcefn to_string_with_causes(&self) -> String
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.