-
-
Notifications
You must be signed in to change notification settings - Fork 676
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 integration of errors with std::error::Error
#760
Comments
It's worth noting that the |
I think removing |
Hey, is anyone working on this? I recently started working with tantivy for some personal projects and ran into this issue almost immediately. If no one currently is, I'd be happy to put up a PR. |
From everything I have seen, it looks like |
The way we handle Error definitely needs to be revisited. The main reason why there is no progress is because I lack bandwidth to study the right option / review PR etc.
Of course yes. |
One potential idea is to just add an additional trait implementation on all error types for the time being? Instead of removing failure immediately it might stand to simply have error types implement |
Looks like we can't use the deprecated attribute on a trait impl. So we would have to warn users in the documentation and/or readme. |
Ah, I didn't realize. How do you feel about having this be a path forward, even if it required deprecation notices included in the documentation? |
It will introduce breaking change that are easy to fix on the client, but that 's ok. Block wand seems to be close to be ready. I think investigating this issue should be the next priority. |
This can be closed now, right? The migration from |
@waywardmonkeys You're right. |
Is your feature request related to a problem? Please describe.
Currently, Tantivy's error types implement
failure::Fail
but notstd::error::Error
.This makes them not directly usable with the
?
operator inside a function returningResult<_, Box<dyn std::error::Error>>
or other catch-all-errors types likeanyhow::Error
.Describe the solution you'd like
A solution for solving this is to directly implement
std::error::Error
for Tantivy's error types.We could these impls manually but there is a library called
thiserror
which provides a derive macro for generating an impls for bothstd::error::Error
andstd::fmt::Display
, in a same manner as withfailure
(#[error("error msg...")]
instead of#[fail(display = "error msg...")]
).PR #756 demonstrate what the migration would look like.
[Optional] describe alternatives you've considered
Staying with
failure
is still an option, but forces the user to usefailure::Error
(and take a dependence on it) to collect Tantivy's errors as astd::error::Error
.The text was updated successfully, but these errors were encountered: