-
Notifications
You must be signed in to change notification settings - Fork 138
Clarify rationale #66
Comments
https://air.mozilla.org/bay-area-rust-meetup-november-2017/ Skip to 1:17:00 Edit: Also a blog post: https://boats.gitlab.io/blog/post/2017-11-16-announcing-failure/ |
Here are some comments on that talk. Note that I maintain
|
My 2 cents:
This is a useful thing. Consider this:
When you return NoSuchElement error you don't have to pay the price for backtrace, as it's expected that our imaginary element is just added by the caller. But if something bad happens that we don't know how to handle we return an error with a backtrace. Also, if OtherError contains a backtrace, you often don't need another traceback (and it's not possible to opt out in error-chain as far as I remember) Note: this is mostly all or nothing thing, i.e. if a library generates a traceback ignoring it or wrapping it into another error doesn't lower the cost (unless it's inlined and optimized out, but we can't always rely on that).
As far as I remember there is a
Technically it works, and technically you don't have to use a Resul type. But it encourages the bad thing.
This is probably about encouraging
There are a lot of places where it makes sense. I use Another case is in |
I don't know if it's correct to assume But I understand that it's a waste when compiling a binary where the backtrace isn't elided for a particular variant even though it never gets used. I'm not sure how to get the best of both worlds except by adding a separate
It can be renamed just like
Right. As I said, it's a fine alternative to The talk mentioned directly returning |
I don't know what you're referring to about I guess #[derive(Debug, ErrorChain)]
enum ContextErrorKind<D: Display> { Inner(D) }
result.chain_err(|| ContextErrorKind::Inner(some_context)) (It could be even shorter if However such a blessed type could just be added to Now if the user does have their own error type, then they might want to retain the original error while still storing a context. Then they would do this with #[derive(Debug, Fail)]
enum Error<D: Display> {
#[fail(display = "{}", context)]
IoError {
context: D,
cause: io::Error,
},
} and this with #[derive(Debug, ErrorChain)]
enum ErrorKind<D: Display> {
#[error_chain(custom)]
#[error_chain(display = "|context, _| context")]
#[error_chain(cause = "|_, cause| cause")]
IoError {
context: D,
cause: io::Error,
},
} So again they're quite even in this regard. (The idea of reusing any field named |
Just to add my own two cents, I have always personally used the Anyway, I think it's worth mentioning the advantages and the potential disadvantages of this crate in the README. |
The crate's readme says the crate intends to replace error management in Rust, taking lessons from problems with quick-error and error-chain.
Could someone clarify what these problems are with the aforementioned crates, and how this crate aims to solve them?
The text was updated successfully, but these errors were encountered: