-
Notifications
You must be signed in to change notification settings - Fork 52
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
Improve fmt::Display
for common error variants
#316
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## jbp-time-error-detail #316 +/- ##
=========================================================
+ Coverage 97.46% 97.60% +0.14%
=========================================================
Files 20 20
Lines 4345 4475 +130
=========================================================
+ Hits 4235 4368 +133
+ Misses 110 107 -3 ☔ View full report in Codecov by Sentry. |
Probably more useful in rustls? At least IIRC we convert these before putting them in the rustls Error. Maybe we should give UnixTime a useful Display impl, too. |
I was leaning the other way. It seems best to me to describe the errors in the same codebase that produces them so that each downstream doesn't have to do it themselves, inconsistently. |
match self { | ||
Self::CertExpired { time, not_after } => write!( | ||
f, | ||
"certificate expired: current time is {}, \ |
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.
maybe clearer to put the units in the message? current UNIX epoch time is: xxx
Yes, but only if we somehow preserve the webpki errors in the rustls API, which we don't do IIRC? |
I think we could expose all this stuff in rustls in one of two ways:
(1) has the downside that users using custom verifiers cannot construct those variants and take advantage of the better errors. Seems minor. |
That's what I was thinking FWIW. |
Maybe we could have an |
I... don't really like that, I'm afraid, because it removes the ability for users to hook actions to different errors (other than string matching, yeurch). |
Okay, well, then we do one boxed webpki error per variant? |
I thought they could take a webpki dep and then downcast but yeah.... very ugly :-/ |
If lifting the display logic to rustls makes for the easiest solution I'm not strictly opposed. I think in reality this crate has few meaningful downstream users outside of Rustls 🤷♂️ |
If we tell them to rely on downcasting we've reintroduced the semver hazard of semver-incompatible webpki upgrades in rustls. |
Not completely sure if we should do this here, or in rustls, or indeed at all?