stalwartlabs / jmap-client

JMAP client library for Rust
Apache License 2.0
64 stars 8 forks source link

Make jmap_client::Error implement std::error::Error using thiserror #6

Closed arlyon closed 1 year ago

arlyon commented 1 year ago

I use anyhow in parts of my application, and noticed that the core error type doesn't implement std::error::Error. I have used thiserror which is a compile-time-only macro for doing this automatically. Incidentally, it also allows us to clean up some boilerplate.

This also means that errors from this library can be used downstream using the same #[from] machinery :)

I decided to move the display impl block further up now that the error display impl block was gone, but I can drop that change.

mdecimus commented 1 year ago

Hi @arlyon , thanks for the PR. Would it be possible to just implement std::error::Error without adding a dependency to thiserror? I am aware that it is a very popular crate but I always try to avoid adding dependencies unless it is really necessary.

arlyon commented 1 year ago

Sure! I will refactor.

arlyon commented 1 year ago

This is, rather embarrassingly, now just a single line of code :sweat_smile: . Got a little lost in cleaning up boilerplate.

mdecimus commented 1 year ago

Thanks, merged!