error-chain icon indicating copy to clipboard operation
error-chain copied to clipboard

Allow multiple errors to be mapped to single local error

Open thegranddesign opened this issue 7 years ago • 2 comments

The reason I sought out this crate was because I wanted to do something like this:

::url::ParseError         => ::my_crate::errors::UrlParseError
::hyper::errors::UriError => ::my_crate::errors::UrlParseError

Unfortunately it doesn't seem like that's currently possible with this crate.

Am I missing something? If not, can it be added?

I'm thinking syntax such as:

foreign_links {
    UrlParseError(::url::ParseError, ::hyper::errors::UriError);
}

thegranddesign avatar Oct 23 '17 23:10 thegranddesign

Yeah, it's not possible for now because UrlParseError must contain an enum with the two variants.

Yamakaky avatar Oct 27 '17 16:10 Yamakaky

You could make a variant in errors { }, and manually write From implementations, maybe? I did that with std::sync::PoisonError (for different reasons)

Lymia avatar Oct 28 '17 06:10 Lymia