#tor #arti #async #retry

retry-error

An error type for an operation that can fail more than once

9 releases

Uses new Rust 2021

0.2.2 Sep 1, 2022
0.2.1 Jun 24, 2022
0.2.0 May 6, 2022
0.1.0 Mar 1, 2022
0.0.0 Jun 24, 2021

#165 in Rust patterns

Download history 342/week @ 2022-06-05 619/week @ 2022-06-12 1034/week @ 2022-06-19 971/week @ 2022-06-26 675/week @ 2022-07-03 667/week @ 2022-07-10 1137/week @ 2022-07-17 770/week @ 2022-07-24 1386/week @ 2022-07-31 245/week @ 2022-08-07 270/week @ 2022-08-14 781/week @ 2022-08-21 2059/week @ 2022-08-28 990/week @ 2022-09-04 1064/week @ 2022-09-11 999/week @ 2022-09-18

5,245 downloads per month
Used in 9 crates (2 directly)

MIT/Apache

15KB
252 lines

retry-error

An error attempt to represent multiple failures.

This crate implements [RetryError], a type to use when you retry something a few times, and all those attempts can fail differently each time. Instead of returning only a single error, it records all of the errors received, in case they are different.

This crate is developed as part of Arti, a project to implement Tor in Rust. It's used by higher-level crates that retry operations.

Example

use retry_error::RetryError;

fn some_operation() -> anyhow::Result<bool> {
   unimplemented!(); // example
}

fn example() -> Result<(), RetryError<anyhow::Error>> {
   const N_ATTEMPTS: usize = 10;
   let mut err = RetryError::in_attempt_to("perform an example operation");
   for _ in 0..N_ATTEMPTS {
       match some_operation() {
           Ok(val) => return Ok(()),
           Err(e) => err.push(e),
       }
   }
   // All attempts failed; return all the errors.
   return Err(err);
}

License: MIT OR Apache-2.0

No runtime deps