pub struct EffectFailure { /* private fields */ }Expand description
A failed action, classified so the runtime knows whether it applied.
// The connection was refused: nothing reached the remote system.
let failure = EffectFailure::ambiguous("connection refused").request_sent(false);Implementations§
Source§impl EffectFailure
impl EffectFailure
Sourcepub fn new(
class: FailureClass,
source: impl Into<Box<dyn Error + Send + Sync>>,
) -> Self
pub fn new( class: FailureClass, source: impl Into<Box<dyn Error + Send + Sync>>, ) -> Self
A failure of class class.
Sourcepub fn transient(source: impl Into<Box<dyn Error + Send + Sync>>) -> Self
pub fn transient(source: impl Into<Box<dyn Error + Send + Sync>>) -> Self
The request did not apply and may succeed if repeated.
Sourcepub fn permanent(source: impl Into<Box<dyn Error + Send + Sync>>) -> Self
pub fn permanent(source: impl Into<Box<dyn Error + Send + Sync>>) -> Self
The request did not apply and will not succeed if repeated.
Sourcepub fn ambiguous(source: impl Into<Box<dyn Error + Send + Sync>>) -> Self
pub fn ambiguous(source: impl Into<Box<dyn Error + Send + Sync>>) -> Self
The request may or may not have applied, e.g. a timeout after sending.
Sourcepub fn rate_limited(
retry_after: Option<Duration>,
source: impl Into<Box<dyn Error + Send + Sync>>,
) -> Self
pub fn rate_limited( retry_after: Option<Duration>, source: impl Into<Box<dyn Error + Send + Sync>>, ) -> Self
The remote system asked the caller to slow down.
Sourcepub fn authentication(source: impl Into<Box<dyn Error + Send + Sync>>) -> Self
pub fn authentication(source: impl Into<Box<dyn Error + Send + Sync>>) -> Self
The credentials were missing or invalid.
The credentials were not allowed to perform the action.
Sourcepub fn validation(source: impl Into<Box<dyn Error + Send + Sync>>) -> Self
pub fn validation(source: impl Into<Box<dyn Error + Send + Sync>>) -> Self
The remote system rejected the request as malformed.
Sourcepub fn request_sent(self, sent: bool) -> Self
pub fn request_sent(self, sent: bool) -> Self
Records whether the request reached the remote system. false turns
an ambiguous failure into a transient one: nothing can have applied.
Sourcepub fn with_retry_after(self, delay: Duration) -> Self
pub fn with_retry_after(self, delay: Duration) -> Self
Adds a minimum retry delay without changing whether the operation may have applied. This is scheduling advice, never evidence that a retry is safe. The runtime persists it for ambiguous outcomes too.
Sourcepub fn retry_after(&self) -> Option<Duration>
pub fn retry_after(&self) -> Option<Duration>
The minimum retry delay, independent of the failure’s disposition.
Sourcepub fn class(&self) -> FailureClass
pub fn class(&self) -> FailureClass
The classification after taking Self::request_sent into account.
Trait Implementations§
Source§impl Debug for EffectFailure
impl Debug for EffectFailure
Source§impl Display for EffectFailure
impl Display for EffectFailure
Source§impl Error for EffectFailure
impl Error for EffectFailure
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
use the Display impl or to_string()