From 5c87cd1eb2c8d5dae8d46a20b86992433491c7d5 Mon Sep 17 00:00:00 2001 From: Nick Mathewson <nickm@torproject.org> Date: Thu, 17 Jun 2021 18:41:47 -0400 Subject: [PATCH] Update retry-error README --- retry-error/README.md | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/retry-error/README.md b/retry-error/README.md index ba7fa24e9c..8a7f27c435 100644 --- a/retry-error/README.md +++ b/retry-error/README.md @@ -1,37 +1,25 @@ -# tor-retry +# retry-error -Helpers to implement retry-related functionality. +An error attempt to represent multiple failures. -Right now, this crate only has an error type that we use when we -retry something a few times, and they all fail. Instead of +This crate implements [`RetryError`], a type to use when you +retry something a few times, and all those attempts. Instead of returning only a single error, it records _all of the errors -received, in case they are different. +received_, in case they are different. -This crate is part of +This crate is developed as part of [Arti](https://gitlab.torproject.org/tpo/core/arti/), a project to implement [Tor](https://www.torproject.org/) in Rust. It's used by higher-level crates that retry operations. -### Design notes - -XXXX We'll want to refactor this one. It might be better in a -crate called retry-error or something, since it isn't -tor-specific. - -The [`RetryError`] type might be more generally useful in the -future, if it gets a stable interface, and if we can make it stop -depending on [`anyhow`]. - -Maybe this error type should be parameterized on an input error type. - ## Example ```rust -use tor_retry::RetryError; +use retry_error::RetryError; const N_ATTEMPTS: usize = 10; -let mut err = RetryError::while_doing("perform an example operation"); +let mut err = RetryError::in_attempt_to("perform an example operation"); for _ in 0..N_ATTEMPTS { match some_operation() { Ok(val) => return Ok(val), -- GitLab