Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NngFail is not compatible with failure::Error #24

Closed
najamelan opened this issue Jan 24, 2019 · 2 comments
Closed

NngFail is not compatible with failure::Error #24

najamelan opened this issue Jan 24, 2019 · 2 comments

Comments

@najamelan
Copy link
Contributor

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
Copy link
Owner

jeikabu commented Jan 24, 2019

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
Copy link
Contributor Author

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.

jeikabu added a commit that referenced this issue Feb 12, 2019
* Numerous improvements to Result and error-handling

- Rename NngResult to more canonical `Result` and get rid of NngReturn
- Rename NngFail to more canonical runng::Error
	- TryFrom conversion for NngFail
	- impl std::error::Error (fix #24)
	- Err and Unknown enums now Errno and UnknownErrno, respectively.
- Rename `NngFail::succeed_then()` to `zero_map()`
	- Zero is `Ok` and then it's the same as `Result::map`
- Tests use fewer glob (*) imports
- impl AsRef/AsMut<[u8]> for Alloc and NngMsg (#25)
	- https://rust-lang-nursery.github.io/api-guidelines/interoperability.html#conversions-use-the-standard-traits-from-asref-asmut-c-conv-traits
@jeikabu jeikabu closed this as completed Apr 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants