Conversation
thomas-zahner
left a comment
There was a problem hiding this comment.
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? |
thomas-zahner
left a comment
There was a problem hiding this comment.
@mre That's a really great approach 👍
Co-authored-by: Thomas Zahner <thomas.zahner@protonmail.ch>
Co-authored-by: Thomas Zahner <thomas.zahner@protonmail.ch>
|
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.