mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 03:05:51 +03:00
[GH-ISSUE #880] The error types should implement std::error::Error #553
Labels
No labels
blocked
breaking-change
bug
bug:critical
bug:tests
cleanup
compliance
compliance
compliance
crate:all
crate:client
crate:native-tls
crate:proto
crate:recursor
crate:resolver
crate:resolver
crate:rustls
crate:server
crate:util
dependencies
docs
duplicate
easy
easy
enhance
enhance
enhance
feature:dns-over-https
feature:dns-over-quic
feature:dns-over-tls
feature:dnsssec
feature:global_lb
feature:mdns
feature:tsig
features:edns
has workaround
ops
perf
platform:WASM
platform:android
platform:fuchsia
platform:linux
platform:macos
platform:windows
pull-request
question
test
tools
tools
trust
unclear
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hickory-dns#553
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rotty on GitHub (Oct 11, 2019).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/880
Describe the bug
When using the error types from
trust-dnswith crates that rely onstd::error::Errorbeing implemented, such as the newanyhowcrate, errors like this are encountered:To Reproduce
Try to use the
trust-dnserror types with any code that requires anstd::error::Errortrait bound.Expected behavior
I would expect the error types to implement
std::error::Error; the impls needed should be relatively trivial.System:
Largely irrelevant, but I used
rustcv1.38.Version:
Crate: Probably all/most of them.
Version: 0.17.0
Additional context
I would be willing to try my hand on preparing a PR to add the missing trait impls.
@rotty commented on GitHub (Oct 11, 2019):
Uh, I've now noticed that adding
std::error::Errorimplementations is not even possible, as they conflict with the blanket implementation inside thefailurecrate:I'm wondering if the use of
failurein a library, especially a potentially widely-used one (such as thetrust-dnsproto and client crates), is the best choice in the long run; it seems the error crate story in rust might converge to crates built onstd::error::Error, at least that was my impression from these reddit threads:anyhowannouncement2019 Q4: Error patterns -Snafuvserr-derive + anyhow`Not being able to provide a
std::error::Errorimplementation would be quite a limitation, if crates such asanyhowget more use. Would you be open to discuss the possibility to change the how handling is done, at least for the lower-leveltrust-dnscrates, so that they can implementstd::error::Error? I'd be willing to try my hand at a PR, once it is determined what the best path forward would be.@rotty commented on GitHub (Oct 11, 2019):
See https://github.com/rotty/tdns-cli/commit/c5e487e724542ee21e00a813e4e7da54af52f214 to get an idea of how it would affect the code when a crate decides to use
anyhowin combination withtrust-dnscurrently. Essentially, you'd have to sprinkle.compat()calls everywhere, combined with the use of the turbofish, in some cases.This issue is not specific to
trust-dns, it affects all crates that expose their use offailure::Fail, and hence cannot implementstd::error::Error; this note in the current versionfailure's README seems relevant as well:@bluejekyll commented on GitHub (Oct 11, 2019):
See also: https://github.com/bluejekyll/trust-dns/pull/855
I'm open to the idea of moving away from Failure, though I really want to maintain some (optional) support for backtrace in errors (that's the largest benefit we get from it at the moment). So if there are options for only using Error (the types are pretty close to being Error compatible), but keeping some optional way of having backtrace (maybe making failure itself an optional dep), I'm open to that.
@rotty commented on GitHub (Oct 11, 2019):
Understood. I think it should be definitely possible to keep backtrace support; we just need to choose a crate that supports that. A potential PR will need to break API in any case though, as
Failno longer would be part of the public API. This will have the advantage that the error handling crate's API should then no longer be exposed publicly, and could be switched at will. I'll hold off working on the code side of things until #849 lands, and investigate crate options in the meantime; I hope to come up with a proposal, or rather a summary of available options, this weekend.@rotty commented on GitHub (Oct 11, 2019):
Ah, and an additional requirement based on #855 is that the replacement crate would have to have optional backtrace support.
@rotty commented on GitHub (Nov 22, 2019):
Well, if you procrastinate long enough, someone else might happen to do the work for you; Yoshua Wuyts has provided an extensive overview over the currently available error handling crates. From reading that alone (no actual research done), it seems like
snafuwill tick all the boxes -- backtrace support, helping with defining structural errors, and being based onstd::error::Error. However, it might make sense to put this issue on hold for a bit more, since it seems backtrace support is well on track for stabilization (see rust-lang/rust#53487). I imagine that for instancethiserrormight include backtrace support once it is stabilized, giving more options to choose from. Maybefailurewill also make a move when the backtrace std API is stabilized.@bluejekyll commented on GitHub (Nov 22, 2019):
This is pretty low priority for me, so It's pretty much up to someone else that really wants it, especially if they want it sooner rather than later.
@rotty commented on GitHub (Nov 23, 2019):
Just to be clear, I was referring to myself as procrastinating, as I said "I hope to come up with a proposal, or rather a summary of available options, this weekend.", which I clearly failed to do, and now the survey has been done in a much more comprehensive way than I would have done it in -- hurray!
This issue is quite low-priority for me as well, FWIW; I just wanted to indicate that I'm still interested in this, and may give it at shot at some point, but that it's maybe a good idea to see how backtrace stabilization plays out.
@bluejekyll commented on GitHub (Nov 23, 2019):
Ah, me misreading things... 😂
Yes. I’d really love it if you have the time to look into this. Honestly we’ve gone through so many iterations on Error types, I’m very tempted to have us just drop back to only using std::Error. If backtrace does get stabilized, that would be great.
@bluejekyll commented on GitHub (Oct 28, 2023):
This issue can be closed, we moved away from
Failurea long time ago in favor ofthiserror