Struct retry_error::RetryError
source · pub struct RetryError<E> { /* private fields */ }
Expand description
An error type for use when we’re going to do something a few times, and they might all fail.
To use this error type, initialize a new RetryError before you
start trying to do whatever it is. Then, every time the operation
fails, use RetryError::push()
to add a new error to the list
of errors. If the operation fails too many times, you can use
RetryError as an Error
itself.
Implementations§
source§impl<E> RetryError<E>
impl<E> RetryError<E>
sourcepub fn in_attempt_to<T: Into<String>>(doing: T) -> Self
pub fn in_attempt_to<T: Into<String>>(doing: T) -> Self
Create a new RetryError, with no failed attempts.
The provided doing
argument is a short string that describes
what we were trying to do when we failed too many times. It
will be used to format the final error message; it should be a
phrase that can go after “while trying to”.
This RetryError should not be used as-is, since when no
Error
s have been pushed into it, it doesn’t represent an
actual failure.
sourcepub fn push<T>(&mut self, err: T)where
T: Into<E>,
pub fn push<T>(&mut self, err: T)where
T: Into<E>,
Add an error to this RetryError.
You should call this method when an attempt at the underlying operation has failed.
Trait Implementations§
source§impl<E: Clone> Clone for RetryError<E>
impl<E: Clone> Clone for RetryError<E>
source§fn clone(&self) -> RetryError<E>
fn clone(&self) -> RetryError<E>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<E: Debug> Debug for RetryError<E>
impl<E: Debug> Debug for RetryError<E>
source§impl<E: Debug + AsRef<dyn Error>> Error for RetryError<E>
impl<E: Debug + AsRef<dyn Error>> Error for RetryError<E>
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
source§impl<E, T> Extend<T> for RetryError<E>where
T: Into<E>,
impl<E, T> Extend<T> for RetryError<E>where
T: Into<E>,
source§fn extend<C>(&mut self, iter: C)where
C: IntoIterator<Item = T>,
fn extend<C>(&mut self, iter: C)where
C: IntoIterator<Item = T>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)