exitfailure 0.4.1

A basic newtype wrapper around failure::Error
Documentation

exitfailure - convenient newtype wrapper for failure::Error

Build Status codecov

exitfailure provides a newtype wrapper around failure::Error that will print a formatted list of error causes in it's Debug trait implementation.

It is intended to be used with rust 1.26 and above's "? in main()" feature (see the tracking issue here).

Example:

#[macro use] extern crate failure;
extern crate exitfailure;

use failure::ResultExt;
use exitfailure::ExitFailure;

fn main() -> Result<(), ExitFailure> {
     Ok(some_fn()?)
}

fn some_fn() -> Result<(), failure::Error> {
     let error = Err(failure::err_msg("root cause failure"));
     Ok(error.context("this is some context".to_string())?)
}

This will print, when executed:

Error: this is some context
caused by: root cause failure

If the environment variable RUST_BACKTRACE=1 is set, then the printing will include whatever backtrace information is provided by the failure::Error that is being wrapped.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.