-
Notifications
You must be signed in to change notification settings - Fork 95
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
Move to thiserror for errors #115
Comments
I have used failures too much to like it, but at the same time I became kinda skeptical of any new rust error-handling library :/ |
The main issues here IMO are the inability for dependents to get more specific error messages, and leaking the failure dependency if you don't want to box everywhere. The convenience of error reporting the way its currently done in avro rs is really for applications, whereas library errors should be as specific and efficient as possible. |
FWIW, failure is now officially deprecated: With all new error handling libs being built around |
The specific library doesn't matter. What matters is the way that errors are presented to dependents IMO. The way in which |
I have been following a bunch of discussions in the community and it does indeed seem that Agreed, let's move to |
Closes flavray#115 This is still a WIP branch, with lots of TODOs and some things about thiserror I still can't wrap my head around. However, the heavy-lifting is done, the failure crate has been removed from the list of dependencies and compilation, tests, benchmarks and linting are all green. The two biggest things I have yet to figure out are: 1. How to deal with the errors manually defined in ser.rs and de.rs: they are publicly available and as soon as I touch anything I hit cryptic serde errors 2. How to make errors like TryFromIntError part of more abstract ones like ParseSchemaError, which could have a source error or just a String description.
Closes flavray#115 This is still a WIP branch, with lots of TODOs and some things about thiserror I still can't wrap my head around. However, the heavy-lifting is done, the failure crate has been removed from the list of dependencies and compilation, tests, benchmarks and linting are all green. The two biggest things I have yet to figure out are: 1. How to deal with the errors manually defined in ser.rs and de.rs: they are publicly available and as soon as I touch anything I hit cryptic serde errors 2. How to make errors like TryFromIntError part of more abstract ones like ParseSchemaError, which could have a source error or just a String description.
* Move from failure to thiserror Closes #115 This is still a WIP branch, with lots of TODOs and some things about thiserror I still can't wrap my head around. However, the heavy-lifting is done, the failure crate has been removed from the list of dependencies and compilation, tests, benchmarks and linting are all green. The two biggest things I have yet to figure out are: 1. How to deal with the errors manually defined in ser.rs and de.rs: they are publicly available and as soon as I touch anything I hit cryptic serde errors 2. How to make errors like TryFromIntError part of more abstract ones like ParseSchemaError, which could have a source error or just a String description. * Update tests/io.rs Co-authored-by: Joel Höner <joel@zyantific.com> * Renaming errors + apply clippy consistently Rename AvroError to Error Removed redundant Error suffix from variants Introduce AvroResult shorthand alias with crate visibility Align clippy invocation in tests with the one in pre-commits * Stop stressing about generic errors and add a couple more sprecific ones * Centralize Ser and De errors into Error The trick was implementing the ser::Error and de::Error trait for crate::errors::Error and return Error::Ser and Error::De variants in the implementation of the custom() method. * SnappyCdcError as struct for consistency * Update CHANGELOG * Update CHANGELOG, README and add a Migration Guide page Co-authored-by: Joel Höner <joel@zyantific.com>
failure
is leaking into the public API and forcing downstream consumers to eitherBox
up the failure error or depend onfailure
if they want to explicitly handle the error.Moreover, error types do not have any precise information in the type about what went wrong.
thiserror
would allow us to provide very specific error variants, as well as avoiding leaking types into the public API and letting downstream consumers handle the variants as they wish.The text was updated successfully, but these errors were encountered: