Skip to content
Snippets Groups Projects
Commit 5c87cd1e authored by Nick Mathewson's avatar Nick Mathewson :family:
Browse files

Update retry-error README

parent b9948679
No related branches found
Tags tor-0.0.9rc1
No related merge requests found
# 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),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment