Function narrate::report::err

source ·
pub fn err(err: &Error)
Expand description

Report an Error to stderr.

The message will consist of a red error: title, followed by the Display impl for the underlying error.

If the Error contains a help message, that will be printed 2 lines below.

Examples

Standard error.

let error = error_from!("invalid configuration");
report::err(&error);
// error: invalid configuration

Error with a help message.

let mut error = Error::new(CliError::Config);
error.add_help("try something else");
report::err(&error);
// error: invalid configuration
//
// try something else
Examples found in repository?
examples/anyhow_add_help.rs (line 24)
22
23
24
25
26
fn main() {
    if let Err(ref err) = outer_fn() {
        report::err(err);
    }
}