Commit Graph

3 Commits

Author SHA1 Message Date
Jeremy Fitzhardinge
4f7f38c1a0 rust/failure_ext: add .chain()/Chain
Summary:
Add a type to explicitly model a causal chain of errors, akin to
error_chain. This looks a lot like Context, but is intended to show the entire
stack of errors rather than deciding that only the top-level one is
interesting.

This adds a `ChainExt` trait, which adds a `.chain_ext(OuterError)` method to
add another step to the causal chain. This is implemented for:
- `F` where `F: Fail`
- `Error`
- `Result<_, F>` where `F: Fail`
- `Result<_, Error>`
- `Future`/`Stream<Error=F>` where `F: Fail`
- `Future`/`Stream<Error=Error>`
- `Chain`

Using it is simple:
```
let res = something_faily().chain_err(LocalError::new("Something amiss"))?;
```
where `something_faily()` returns any of the above types.

(This is done by adding an extra dummy marker type parameter to the `ChainExt`
trait so that it can avoid problems with the coherence rules - thanks for the idea @[100000771202578:kulshrax]!)

Reviewed By: lukaspiatkowski

Differential Revision: D9394192

fbshipit-source-id: 0817844d283b3900d2555f526c2683231ca7fe12
2018-09-06 14:24:08 -07:00
Jeremy Fitzhardinge
3d24be22aa tp2/rust: rust-crates-io update
Summary: Update rust-crates-io. Small changes needed for failure 0.1.2 update.

Reviewed By: rahulg

Differential Revision: D9125235

fbshipit-source-id: fd98af065b54e207fcb2c3cfc9dd9a2d325cc6c8
2018-08-02 10:06:47 -07:00
Lukas Piatkowski
b03d5cf630 'Re-sync with internal repository' 2018-07-26 09:09:45 -07:00