Added chain_err
method to Error implementations
#141
Conversation
CHANGELOG.md
Outdated
@@ -1,5 +1,7 @@ | |||
# Unreleased | |||
|
|||
- Add a new method for `Error`: `caused`. _PR to be added_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can now add the PR number ^^
src/error_chain.rs
Outdated
pub fn caused<F, EK>(self, error: F) -> $error_name | ||
where F: FnOnce() -> EK, EK: Into<$error_kind_name> { | ||
$error_name::with_chain(self, Self::from_kind(error().into())) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you consider adding this to the ChainedErr
trait?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had not; it looks like it should be straightforward enough to include. I'll put that in now.
Sorry for the delay. Could you add some doc in lib.rs? |
Yes. Is |
CHANGELOG.md
Outdated
@@ -1,5 +1,7 @@ | |||
# Unreleased | |||
|
|||
- [Add a new method for `Error`: `caused`.](https://github.com/brson/error-chain/pull/141) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to change description caused
-> chain_err
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch; I've fixed that and pushed a new update.
caused
method to Error implementationschain_err
method to Error implementations
Sorry, I had a lot of things to do these times. SGTM! |
@Yamakaky thanks for the merge; do you mind publishing a new release with this and the other changes sitting in master? |
Add a new method
Error::caused(self, error: F) -> Error where F : FnOnce() -> EK, EK : Into<ErrorKind>
to the generated error type. This enables chaining on error instances exposed by methods such asResult::map_err
without inventing a new Result wrapper. This aims to address #40Open Questions
chain_err
to align withResultExt
?