pub struct ActivityError {
pub code: String,
pub message: String,
pub retryable: bool,
pub cost_usd: Option<Decimal>,
pub usage: Vec<UsageEntry>,
}Expand description
An activity failure, reported to the server via
POST /api/v1/activities/{id}/fail.
The retryable flag is the contract-critical part: retryable failures are
re-queued by the orchestrator (up to the activity’s retry limit), terminal
failures are not. Construct with ActivityError::retryable or
ActivityError::terminal so the distinction is always explicit.
A failed attempt may still have spent money: attach what it cost with
ActivityError::with_usage / ActivityError::with_cost so the spend
is recorded and counted against workflow budgets.
Any error convertible to anyhow::Error can be propagated with ? from
handlers returning Result<_, ActivityError> via
.map_err(ActivityError::from)?, or directly from anyhow::Error; it
becomes a retryable EXECUTION_ERROR.
Fields§
§code: StringError code (for categorization, e.g. “PAYMENT_DECLINED”)
message: StringHuman-readable error message
retryable: boolWhether the orchestrator should retry this activity
cost_usd: Option<Decimal>Cost spent before the failure that is NOT covered by usage entries
usage: Vec<UsageEntry>Per-LLM-call usage made before the failure
Implementations§
Source§impl ActivityError
impl ActivityError
Sourcepub fn retryable(code: impl Into<String>, message: impl Into<String>) -> Self
pub fn retryable(code: impl Into<String>, message: impl Into<String>) -> Self
A failure the orchestrator should retry (transient conditions: timeouts, network errors, rate limits).
Sourcepub fn terminal(code: impl Into<String>, message: impl Into<String>) -> Self
pub fn terminal(code: impl Into<String>, message: impl Into<String>) -> Self
A terminal failure that will not improve on retry (bad input, business-rule rejection).
Sourcepub fn with_cost(self, cost_usd: Decimal) -> Self
pub fn with_cost(self, cost_usd: Decimal) -> Self
Attach cost spent before the failure that is not covered by usage entries.
Sourcepub fn with_usage(self, usage: Vec<UsageEntry>) -> Self
pub fn with_usage(self, usage: Vec<UsageEntry>) -> Self
Attach per-LLM-call usage made before the failure.
Trait Implementations§
Source§impl Clone for ActivityError
impl Clone for ActivityError
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)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Auto Trait Implementations§
impl Forget for ActivityError
impl Freeze for ActivityError
impl Move for ActivityError
impl RefUnwindSafe for ActivityError
impl Send for ActivityError
impl Sync for ActivityError
impl Unpin for ActivityError
impl UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.