exitfailure 0.2.1

A basic newtype wrapper around failure::Error
Documentation

exitfailure - convienent newtype wrapper for failure::Error

Build Status

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