aerospike / aerospike-client-rust

Rust client for the Aerospike database
https://www.aerospike.com/
Other
82 stars 29 forks source link

`error-chain` -> `thiserror` port #131

Open databasedav opened 1 year ago

databasedav commented 1 year ago

@khaf i believe i'm almost done here but need some guidance on a few things

khaf commented 1 year ago

@databasedav Thanks for the quick turn around! I looked around for a few hours and from what I understand thus far:

  1. There is no easy workaround. thiserror uses an unstable feature for backtraces that until final release can only be used via nightly. I have not been able to come up with a solution myself. Maybe @jonas32 can chime in.
  2. We have to implement it ourselves. This example could be helpful: https://github.com/jsvana/async-minecraft-ping/pull/8/files
  3. No need for bail!. The idea with moving to thiserror was to have idiomatic error handling.
databasedav commented 1 year ago

@khaf thoughts on using error-stack? i'm not a big fan of how the "context nesting" strategy pollutes the library level with having to deal with the Generic/WithContext error wrappers, embedding the context api into the error struct with a trait is much cleaner/more idiomatic imo

khaf commented 1 year ago

@databasedav I'm pretty sure I had answered this right away, but seeing that my response is missing, I assume I left to research and reflect and forgot to come back to it. Sorry about that.

I have nothing against the error-stack. As long as the library does not impose runtime cost, leaking abstractions and limitation upon us, I'm fine with it.

I'm open to the idea, let me know how it goes.

khaf commented 7 months ago

@databasedav I have updated this PR to finish the work you started. The code compiles now. Having looked at error-stack, it shares an issue with anyhow in that it shows up in the public API. It is also too complicated for our needs, and has a much smaller user base in comparison to thiserror. The current implementation is not complete, since I'd like to add backtrace and source to all errors to easy debugging, but I think we are on the right track. To chain errors, I have introduced a Wrapped option, which boxes errors inside in a chain. I will have to rename it to something better (Chain maybe? Open to suggestions) and implement some public API to allow easy introspection. Let me know what you think.