-
-
Notifications
You must be signed in to change notification settings - Fork 183
Refactor error reporting #1731
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
Refactor error reporting #1731
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your efforts. This will improve UX quite a lot!
|
@thomas-zahner Thanks for the excellent feedback! I've addressed all your comments: Changes Made:
Reasoning: The original approach with individual if contains() chains was repetitive and hard to maintain. I've implemented an ErrorRules builder that encapsulates the pattern matching logic: ErrorRules::new()
.rule(&["expired", "NotValidAtThisTime"], "SSL certificate expired. Site needs to
renew certificate")
.rule(&["hostname", "NotValidForName"], "SSL certificate hostname mismatch. Check
URL spelling")
.fallback("SSL certificate error. Check certificate validity")
.match_error(error_msg)This approach provides better maintainability: Rules are declarative, and adding new patterns ist just adding new I hope the code now more readable. What do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mre That's a really great approach 👍
Co-authored-by: Thomas Zahner <[email protected]>
Co-authored-by: Thomas Zahner <[email protected]>
|
Thanks for the thorough review, @thomas-zahner |
Related to #1723
The goal is to get as much information from the error as possible.
This started out as an experiment, but now I think it would be useful to provide better error messages.
The downside is that we'd have to pay close attention to changes in upstream error messages (in hyper/reqwest). I feel like that is a sensible tradeoff to make, given that the error messages rarely change, and we merely check for specific, relatively "robust" keywords.