Open Yamakaky opened 7 years ago
What I said here is still mostly true. Compared to the error_chain!
macro, here the user needs to declare an enum, remember to mark it pub
, remember to derive Debug
, and remember to provide a Msg(String)
member. Then for each variant, instead of nice function syntax for display and description they have to make a separate function or embed it in a string.
You can see an example at https://github.com/Arnavion/fac-rs/blob/2a8f67bb/factorio-mods-local/src/error.rs That repo is probably the only bunch of crates that use it. I've not heard of anyone else using it nor received any feedback.
The error_chain!
macro has its place for convenience. I would never go as far as replacing it entirely. At best this can function as a (currently experimental) alternative.
I'm thinking: can't we modify error_chain!
to use derive-error-chain
in the background? That way we would have more code in common.
It might be possible.
What do you think @brson?
(I should clarify that I think it might be possible, not that it's a good idea. It seems unnecessarily roundabout for a regular macro to generate input for another proc macro.)
An update to my earlier sentiments, based on the last few months:
That repo [Arnavion/fac-rs] is probably the only bunch of crates that use it. I've not heard of anyone else using it nor received any feedback.
This is no longer true since atleast dotenv uses it, and one user has submitted a PR to add support for generic errorkinds.
The
error_chain!
macro has its place for convenience. I would never go as far as replacing it entirely.
However upstream is considering replacing it entirely. https://github.com/rust-lang-nursery/error-chain/issues/170
At best this can function as a (currently experimental) alternative.
I don't consider this crate experimental any more.
With macros 1.1 on stable, do you think your crate could replace the upstream
error_chain
?