Skip to content
This repository has been archived by the owner on Feb 6, 2022. It is now read-only.

Replace error_chain! #11

Open
Yamakaky opened this issue Feb 6, 2017 · 6 comments
Open

Replace error_chain! #11

Yamakaky opened this issue Feb 6, 2017 · 6 comments
Milestone

Comments

@Yamakaky
Copy link

Yamakaky commented Feb 6, 2017

With macros 1.1 on stable, do you think your crate could replace the upstream error_chain?

@Arnavion
Copy link
Owner

Arnavion commented Feb 6, 2017

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.

@Yamakaky
Copy link
Author

Yamakaky commented Feb 6, 2017

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.

@Arnavion
Copy link
Owner

Arnavion commented Feb 6, 2017

It might be possible.

@Yamakaky
Copy link
Author

Yamakaky commented Feb 6, 2017

What do you think @brson?

@Arnavion
Copy link
Owner

Arnavion commented Feb 6, 2017

(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.)

@Arnavion
Copy link
Owner

Arnavion commented Aug 7, 2017

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. rust-lang-deprecated/error-chain#170

At best this can function as a (currently experimental) alternative.

I don't consider this crate experimental any more.

@Arnavion Arnavion added this to the upstream milestone Jun 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants