pub enum ActivityError {
Retry(String),
NonRetry(String),
}Expand description
Error type for activity operations that supports retry semantics.
This enum distinguishes between errors that should trigger a retry and those that indicate permanent failure.
§Examples
use runner_q::ActivityError;
use runner_q::ActivityHandlerResult;
// Retryable error - temporary network issue
let retry_error = ActivityError::Retry("Network timeout".to_string());
// Non-retryable error - invalid input data
let permanent_error = ActivityError::NonRetry("Invalid user ID format".to_string());
// Using in activity handlers
fn process_user_data(payload: serde_json::Value) -> ActivityHandlerResult {
let user_id = payload["user_id"].as_str()
.ok_or_else(|| ActivityError::NonRetry("Missing user_id".to_string()))?;
if user_id.is_empty() {
return Err(ActivityError::NonRetry("Empty user_id".to_string()));
}
// Simulate processing that might fail temporarily
if payload["retry_processing"].as_bool().unwrap_or(false) {
Err(ActivityError::Retry("Processing failed, will retry".to_string()))
} else {
Ok(Some(serde_json::json!({"processed": true})))
}
}Variants§
Retry(String)
Error that should trigger a retry attempt.
Use this for temporary failures like network timeouts, temporary service unavailability, or other transient issues that might resolve on retry.
NonRetry(String)
Error that should not trigger a retry.
Use this for permanent failures like invalid input data, authentication errors, or other issues that won’t be resolved by retrying.
Trait Implementations§
Source§impl Debug for ActivityError
impl Debug for ActivityError
Source§impl Display for ActivityError
impl Display for ActivityError
Source§impl Error for ActivityError
impl Error for ActivityError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl From<Error> for ActivityError
impl From<Error> for ActivityError
Auto Trait Implementations§
impl Freeze for ActivityError
impl RefUnwindSafe for ActivityError
impl Send for ActivityError
impl Sync for ActivityError
impl Unpin for ActivityError
impl UnwindSafe for ActivityError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more