Hacker News new | ask | show | jobs
by bvinc 3399 days ago
> Support for Result<Value, Error1 | Error2 | Error3> would be helpful. Or may be support for easily converting one type of error to another.

It sounds like you want to create a new error type that's an enum of Error1, Error2, Error3 and then just implement the From traits. Then you can use ? with no boilerplate error handling.

I'm sure you've already considered this though. Why wouldn't that work for you?

2 comments

Declaring the new enum and implementing it are the boilerplate.
Lots of typing and mental overload. Since we are talking about ergonomics and reducing friction, it would be good to make Result handling easier.
The From trait can be derived using my derive_more crate. That would at least decrease the boilerplate a bit.

http://jeltef.github.io/derive_more/derive_more/