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

How do I produce meaningful error messages? #234

Open
flisk opened this issue Sep 27, 2021 · 1 comment
Open

How do I produce meaningful error messages? #234

flisk opened this issue Sep 27, 2021 · 1 comment
Labels
enhancement good first issue An issue that would be good for new contributors!

Comments

@flisk
Copy link

flisk commented Sep 27, 2021

First off, thank you very much for your work on this crate. I've had a lot of fun maintaining my IRC bot written against this library for over a year now.

I'm a little confused about how I can produce meaningful user-facing error messages with 0.15.0. Unfortunately the examples don't seem to shed any light on this.

My application performs reconnect attempts in a loop and reports errors by log, so I'd like to catch any type of error in that loop, report it to the user, and proceed to reconnect. I'm able to obtain an irc::error::Error from the failure::Errors falling out of client.identify(), stream.next() and so on, but simply .to_string()'ing or printing these errors produces very vague results. For example:

an io error occurred

Debug-formatting produces more useful but less user-friendly output:

Io(Custom { kind: Uncategorized, error: "failed to lookup address information: Name or service not known" })

I've taken a look at error.rs. Is my application supposed to match and implement specific behavior for every error type, or is the vagueness of these error messages unintended?

I'd appreciate any pointers.

@WhyNotHugo
Copy link

You probably want to render the nested error here:

https://docs.rs/irc/0.15.0/src/irc/error.rs.html#19-102

The API for this is the second example:

https://docs.rs/thiserror/latest/thiserror/#example

I'm not a maintainer here, but a PR patching this sounds pretty reasonable.

@aatxe aatxe added enhancement good first issue An issue that would be good for new contributors! labels Dec 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement good first issue An issue that would be good for new contributors!
Projects
None yet
Development

No branches or pull requests

3 participants