Last active
December 15, 2018 05:37
-
-
Save iopq/66fd8ea54cc4557a1f0115118f876dcf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[macro_use] | |
extern crate failure; | |
use failure::Fail; | |
#[derive(Debug, Fail)] | |
#[fail(display = "my error")] | |
struct MyError; | |
#[derive(Debug, Fail)] | |
#[fail(display = "my wrapping error")] | |
struct WrappingError(#[fail(cause)] MyError); | |
fn bad_function() -> Result<(), WrappingError> { | |
Err(WrappingError(MyError)) | |
} | |
fn main() { | |
for cause in Fail::iter_causes(&bad_function().unwrap_err()) { | |
println!("{}", cause); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment