pub fn anyhow_err_full(err: &Error)
Expand description

Report an anyhow::Error to stderr, printing a list of causes

The message will consist of a red error: title, followed by the Display impl for the underlying error. Each subsequent wrapped error will have a plain cause: title.

Example

Context wrapped error.

use narrate::report;
use anyhow::{Context, Result};

fn setup_config() -> Result<()> {
    ...
    let user_config = parse_config_file(&path)
        .with_context(|| format!("invalid config file: `{}`", &path))?;
    ...
}

fn main() {
    ...
    let res = setup_config().context("invalid configuration");
    if let Err(ref err) = res {
        report::anyhow_err_full(err);
        // error: invalid configuration
        // cause: invalid config file: `config.toml`
        // cause: missing key: `author`
    }
    ...
}