tailhook/quick-error

Allow wrapping of errors

Binero opened this issue · 2 comments

It would be nice if something like this was possible:

quick_error! {
    #[derive(Debug)]
    pub enum MagicHeaderParseError {
        Io(error: IoError) {
            description(error.description())
            display("{}", error.display())
            cause(error.cause())
            from(error: IoError) -> (error)
        }
    }
}

Right now this doesn't work, as description(...) only accepts string literals, and cause cannot take Options.

Here is a good example. The only issue is that cause isn't forwarded immediately. But I think the use case for cause is to walk through the whole chain anyway, so it shouldn't be a problem.

Thank you. I see. I guess this can be closed as a duplicate then.