jeikabu / runng

MIT License
25 stars 3 forks source link

NngFail is not compatible with failure::Error #24

Closed najamelan closed 5 years ago

najamelan commented 5 years ago

It would be nice to be able to use the ? operator in functions that can also throw other errors than NngFail. The most recent work on making error handling smoother in rust is the failure crate. It would be nice to provide compatibility with that. It can be done by deriving failure::Fail for your error, or if you don't want the extra dependency, implementing std::error::Error as described here in the docs.

If you're low on time I could make a pull request for this one, but you'd have to decide whether you prefer std::error or failure.

btw off topic: I am trying to see how I will use runng and actix in my project, so I made a small test repository where I try different ways to get it to work. It might at some point serve as example code for runng. Currently it's not very documented, but just wanted to let you know it exists. Every commit is a different working example. It will definitely evolve over the next few days, because it's not at all satisfying right now. Next I will look into the async api and improve the way I invoke actix.

jeikabu commented 5 years ago

Yeah, revisiting NngFail/Return/etc has been on my to-do list, think there's a few FIXMEs sprinkled around as well. Was looking at the error-chain crate, but I hadn't heard things are headed towards failure.

najamelan commented 5 years ago

I admit I have never used error-chain, but I think the approach of failure makes a lot of sense and is an evolution from lessons learned from error-chain. So much that withoutboats is now employed by mozilla and they are reworking error handling in the standard library.