Comments (6)
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.
from derive-error-chain.
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.
from derive-error-chain.
It might be possible.
from derive-error-chain.
What do you think @brson?
from derive-error-chain.
(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.)
from derive-error-chain.
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.
from derive-error-chain.
Related Issues (20)
- Port error-chain's tests
- Support specifying custom `Error::cause`
- Make Sync configurable
- Future alias? HOT 1
- Make Msg optional
- Rename `#[derive(error_chain)]` to `#[derive(ErrorChain)]`
- Don't require `ErrorKind` to be `pub`
- Update pm2, syn, quote for nightly breakages
- Switch to new proc_macro_derive
- Undocumented dependencies HOT 4
- Support deriving on structs
- Update for error-chain v0.12.0 HOT 4
- Allow backtrace to be optional
- Update example and tests for #[cfg] on variants
- Use upstream traits - Backtrace, ChainedError, ErrorChainIter, ResultExt, State HOT 18
- Add `const("some string literal")` as a shorthand for `description()` HOT 2
- Add `const("some string literal with {parameters}")` as a shorthand for `display()` HOT 4
- Change display and description to receive all members instead of a tuple of the members
- Documentation updates
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from derive-error-chain.