-
Notifications
You must be signed in to change notification settings - Fork 8
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
anyhow Errors make it difficult to use this crate #43
Comments
Yes, would be better to return a |
I had originally used |
That is actually a myth in most cases. The way And in this case the library is so trivial that an EDIT: sorry if it came of as a little aggressive, I just don't like "wisdom of the crowd" being justified by it's "the wisdom of the crowd". I'm happy to hear why thiserror is perfectly suited for this crate. |
No worries, I understand
I started down this path but there are a couple errors that are explicitly handled in this crate. I believe they are ok to switch to
For case 1, if the buildid is less than 2 bytes we should return |
I'd suggest returning an error if there is corruption or a transient error and #[derive(Debug, Error)]
pub enum CorruptObject {
#[error("build id is too short")]
BuildIdTooShort,
...
} This way if someone really wants to handle the corrupt/transient errors differently they can use |
I've created a PR #49 that partially completes this work. It adds in the |
FWIW, having just run into a similar issue attempting to use this crate for a small tool, I can say that at a bare minimum whatever error type this crate returns needs to be exported as part of the public API. At present it's not possible to refer to A bit late, but in re:
I simply meant " To the original point of this issue: |
Not really that bothered since I'm not currently using locate-dwarf. But you're not going to convince me that thiserror is better for library crates than anyhow for various reasons I mentioned. It may be that in some cases it's a better fit when done correctly. But if you're just wrapping every error from every dependency in a new enum it's not the case. And please make sure that at least the backtrace is captured and unwrapping an error actually displays were the error was constructed and not where it was unwrapped. |
I'm trying to integrate
locate-dwarf
into my own crate but the usage ofanyhow
has made it difficult for me to make decisions based on the errors returned. For example, I want to take a different action if an io error occurred inlocate_debug_symbols
versus if there is no debug pointer to be found.I'd be willing to change this crate to use
thiserror
if you are open to it?The text was updated successfully, but these errors were encountered: