reliability_toolkit/error.rs
1//! Error types shared across the crate.
2
3use std::time::Duration;
4
5use thiserror::Error;
6
7/// Errors that can be returned by reliability primitives themselves
8/// (as opposed to errors from the wrapped operation).
9#[derive(Debug, Error)]
10pub enum ToolkitError {
11 /// The circuit breaker is currently open and rejected the call without invoking it.
12 #[error("circuit breaker is open (will retry after {retry_after:?})")]
13 CircuitOpen {
14 /// How long the breaker expects to remain open.
15 retry_after: Duration,
16 },
17
18 /// The bulkhead has been closed and is no longer accepting permits.
19 #[error("bulkhead is closed")]
20 BulkheadClosed,
21
22 /// Retry exhausted its attempt budget without a success.
23 #[error("retry exhausted after {attempts} attempts")]
24 RetryExhausted {
25 /// How many attempts were made before giving up.
26 attempts: u32,
27 },
28}