5 releases

0.2.3 Feb 5, 2019
0.2.2 Feb 5, 2019
0.2.1 Feb 5, 2019
0.2.0 Feb 5, 2019
0.1.0 Jan 21, 2019

#695 in Command-line interface

MIT/Apache

4KB
56 lines

Minimalist helper library for providing contextual errors that display in the traditional "context: cause" format. Useful for cases where the primary goal of a Result is to convey detailed diagnostics to a user.

Pairs well with type Result<T> = std::result::Result<T, Box<std::error::Error + Send + Sync>>;

use std::fs;
use err_ctx::ResultExt;
let result = fs::read("foo.txt").ctx("reading foo.txt");
assert!(result.unwrap_err().to_string().starts_with("reading foo.txt: "));

No runtime deps