Skip to main content

DurableError

Enum DurableError 

Source
#[non_exhaustive]
pub enum DurableError {
Show 17 variants
#[non_exhaustive]
ReplayMismatch { expected: String, actual: String, position: usize, },
#[non_exhaustive]
CheckpointFailed { operation_name: String, source: Box<dyn Error + Send + Sync>, },
#[non_exhaustive]
Serialization { type_name: String, source: Error, },
#[non_exhaustive]
Deserialization { type_name: String, source: Error, }, AwsSdk(Box<Error>), AwsSdkOperation(Box<dyn Error + Send + Sync>),
#[non_exhaustive]
StepRetryScheduled { operation_name: String, },
#[non_exhaustive]
WaitSuspended { operation_name: String, },
#[non_exhaustive]
CallbackSuspended { operation_name: String, callback_id: String, },
#[non_exhaustive]
CallbackFailed { operation_name: String, callback_id: String, error_message: String, },
#[non_exhaustive]
InvokeSuspended { operation_name: String, },
#[non_exhaustive]
InvokeFailed { operation_name: String, error_message: String, },
#[non_exhaustive]
ParallelFailed { operation_name: String, error_message: String, },
#[non_exhaustive]
MapFailed { operation_name: String, error_message: String, },
#[non_exhaustive]
ChildContextFailed { operation_name: String, error_message: String, },
#[non_exhaustive]
StepTimeout { operation_name: String, },
#[non_exhaustive]
CompensationFailed { operation_name: String, error_message: String, },
}
Expand description

Represent all errors that can occur within the durable-lambda SDK.

Each variant carries rich context for diagnosing failures. Variants are constructed via static methods (e.g., DurableError::replay_mismatch) to keep internal fields private.

§Examples

use durable_lambda_core::error::DurableError;

// Create a replay mismatch error.
let err = DurableError::replay_mismatch("Step", "Wait", 3);
assert!(err.to_string().contains("position 3"));
assert!(err.to_string().contains("expected Step"));

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

#[non_exhaustive]
ReplayMismatch

A replay operation encountered a different operation type or name than what was recorded in the execution history.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§expected: String
§actual: String
§position: usize
§

#[non_exhaustive]
CheckpointFailed

A checkpoint write or read operation failed.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§operation_name: String
§source: Box<dyn Error + Send + Sync>
§

#[non_exhaustive]
Serialization

Serialization of a value to JSON failed.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§type_name: String
§source: Error
§

#[non_exhaustive]
Deserialization

Deserialization of a value from JSON failed.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§type_name: String
§source: Error
§

AwsSdk(Box<Error>)

A general AWS SDK error occurred.

§

AwsSdkOperation(Box<dyn Error + Send + Sync>)

A specific AWS API operation error occurred.

§

#[non_exhaustive]
StepRetryScheduled

A step retry has been scheduled — the function should exit.

The SDK has checkpointed a RETRY action. The durable execution server will re-invoke the Lambda after the configured delay. The handler must propagate this error to exit cleanly.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§operation_name: String
§

#[non_exhaustive]
WaitSuspended

A wait operation has been checkpointed — the function should exit.

The SDK has sent a START checkpoint with the wait duration. The durable execution server will re-invoke the Lambda after the timer expires. The handler must propagate this error to exit cleanly.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§operation_name: String
§

#[non_exhaustive]
CallbackSuspended

A callback is pending — the function should exit and wait for an external signal.

The callback has been registered but no success/failure signal has been received yet. The handler must propagate this error to exit. The server will re-invoke the Lambda when the callback is signaled.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§operation_name: String
§callback_id: String
§

#[non_exhaustive]
CallbackFailed

A callback failed, was cancelled, or timed out.

The external system signaled failure, or the callback exceeded its configured timeout. The error message contains details from the callback’s error object.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§operation_name: String
§callback_id: String
§error_message: String
§

#[non_exhaustive]
InvokeSuspended

An invoke operation is pending — the function should exit while the target Lambda executes.

The invoke START checkpoint has been sent. The server will invoke the target function asynchronously and re-invoke this Lambda when the target completes.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§operation_name: String
§

#[non_exhaustive]
InvokeFailed

An invoke operation failed, timed out, or was stopped.

The target Lambda function returned an error, or the invoke exceeded its configured timeout.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§operation_name: String
§error_message: String
§

#[non_exhaustive]
ParallelFailed

A parallel operation failed.

One or more branches encountered an unrecoverable error during concurrent execution.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§operation_name: String
§error_message: String
§

#[non_exhaustive]
MapFailed

A map operation failed.

An unrecoverable error occurred during map collection processing. Individual item failures are captured in the BatchResult rather than propagated as this error.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§operation_name: String
§error_message: String
§

#[non_exhaustive]
ChildContextFailed

A child context operation failed.

The child context’s closure returned an error, or the child context was found in a failed/cancelled/timed-out state during replay.

§Examples

use durable_lambda_core::error::DurableError;

let err = DurableError::child_context_failed("sub_workflow", "closure returned error");
assert!(err.to_string().contains("sub_workflow"));
assert!(err.to_string().contains("closure returned error"));

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§operation_name: String
§error_message: String
§

#[non_exhaustive]
StepTimeout

A step exceeded its configured timeout.

The step closure did not complete within the duration configured via StepOptions::timeout_seconds. The spawned task is aborted and this error is returned immediately.

§Examples

use durable_lambda_core::error::DurableError;

let err = DurableError::step_timeout("my_op");
assert!(err.to_string().contains("my_op"));
assert!(err.to_string().contains("timed out"));
assert_eq!(err.code(), "STEP_TIMEOUT");

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§operation_name: String
§

#[non_exhaustive]
CompensationFailed

One or more compensation steps failed during saga rollback.

The saga/compensation pattern ran run_compensations() and one or more compensation closures returned an error. All compensations are attempted regardless; this error captures the first/combined failure.

§Examples

use durable_lambda_core::error::DurableError;

let err = DurableError::compensation_failed("charge_payment", "payment reversal failed");
assert!(err.to_string().contains("charge_payment"));
assert!(err.to_string().contains("payment reversal failed"));
assert_eq!(err.code(), "COMPENSATION_FAILED");

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§operation_name: String
§error_message: String

Implementations§

Source§

impl DurableError

Source

pub fn replay_mismatch( expected: impl Into<String>, actual: impl Into<String>, position: usize, ) -> DurableError

Create a replay mismatch error.

Use when the replay engine encounters an operation at a history position that doesn’t match the expected operation type or name.

§Examples
use durable_lambda_core::error::DurableError;

let err = DurableError::replay_mismatch("Step", "Wait", 5);
assert!(err.to_string().contains("expected Step"));
assert!(err.to_string().contains("got Wait"));
assert!(err.to_string().contains("position 5"));
Source

pub fn checkpoint_failed( operation_name: impl Into<String>, source: impl Error + Send + Sync + 'static, ) -> DurableError

Create a checkpoint failure error.

Use when writing or reading a checkpoint to/from the durable execution backend fails.

§Examples
use durable_lambda_core::error::DurableError;
use std::io;

let source = io::Error::new(io::ErrorKind::TimedOut, "connection timed out");
let err = DurableError::checkpoint_failed("charge_payment", source);
assert!(err.to_string().contains("charge_payment"));
Source

pub fn serialization( type_name: impl Into<String>, source: Error, ) -> DurableError

Create a serialization error.

Use when serde_json::to_value or serde_json::to_string fails for a checkpoint value.

§Examples
use durable_lambda_core::error::DurableError;

// Simulate a serde error by deserializing invalid JSON.
let serde_err = serde_json::from_str::<i32>("not a number").unwrap_err();
let err = DurableError::serialization("OrderPayload", serde_err);
assert!(err.to_string().contains("OrderPayload"));
Source

pub fn deserialization( type_name: impl Into<String>, source: Error, ) -> DurableError

Create a deserialization error.

Use when serde_json::from_value or serde_json::from_str fails for a cached checkpoint value during replay.

§Examples
use durable_lambda_core::error::DurableError;

// Simulate a serde error by deserializing invalid JSON.
let serde_err = serde_json::from_str::<i32>("not a number").unwrap_err();
let err = DurableError::deserialization("OrderResult", serde_err);
assert!(err.to_string().contains("OrderResult"));
assert!(err.to_string().contains("deserialize"));
Source

pub fn aws_sdk_operation( source: impl Error + Send + Sync + 'static, ) -> DurableError

Create an AWS API operation error.

Use for specific AWS API call failures (e.g., SdkError from individual operations) that are distinct from the general aws_sdk_lambda::Error.

§Examples
use durable_lambda_core::error::DurableError;
use std::io;

let source = io::Error::new(io::ErrorKind::Other, "service unavailable");
let err = DurableError::aws_sdk_operation(source);
assert!(err.to_string().contains("service unavailable"));
Source

pub fn step_retry_scheduled(operation_name: impl Into<String>) -> DurableError

Create a step retry scheduled signal.

Use when a step has been checkpointed with RETRY and the function should exit so the server can re-invoke after the configured delay.

§Examples
use durable_lambda_core::error::DurableError;

let err = DurableError::step_retry_scheduled("charge_payment");
assert!(err.to_string().contains("charge_payment"));
Source

pub fn wait_suspended(operation_name: impl Into<String>) -> DurableError

Create a wait suspended signal.

Use when a wait operation has been checkpointed with START and the function should exit so the server can re-invoke after the timer.

§Examples
use durable_lambda_core::error::DurableError;

let err = DurableError::wait_suspended("cooldown_delay");
assert!(err.to_string().contains("cooldown_delay"));
Source

pub fn callback_suspended( operation_name: impl Into<String>, callback_id: impl Into<String>, ) -> DurableError

Create a callback suspended signal.

Use when a callback has been registered but not yet signaled. The handler must propagate this to exit so the server can wait for the external signal.

§Examples
use durable_lambda_core::error::DurableError;

let err = DurableError::callback_suspended("approval", "cb-123");
assert!(err.to_string().contains("approval"));
assert!(err.to_string().contains("cb-123"));
Source

pub fn callback_failed( operation_name: impl Into<String>, callback_id: impl Into<String>, error_message: impl Into<String>, ) -> DurableError

Create a callback failed error.

Use when a callback was signaled with failure, cancelled, or timed out.

§Examples
use durable_lambda_core::error::DurableError;

let err = DurableError::callback_failed("approval", "cb-123", "rejected by reviewer");
assert!(err.to_string().contains("approval"));
assert!(err.to_string().contains("cb-123"));
assert!(err.to_string().contains("rejected by reviewer"));
Source

pub fn invoke_suspended(operation_name: impl Into<String>) -> DurableError

Create an invoke suspended signal.

Use when an invoke START checkpoint has been sent and the function should exit while the target Lambda executes.

§Examples
use durable_lambda_core::error::DurableError;

let err = DurableError::invoke_suspended("call_processor");
assert!(err.to_string().contains("call_processor"));
Source

pub fn invoke_failed( operation_name: impl Into<String>, error_message: impl Into<String>, ) -> DurableError

Create an invoke failed error.

Use when the target Lambda returned an error, timed out, or was stopped.

§Examples
use durable_lambda_core::error::DurableError;

let err = DurableError::invoke_failed("call_processor", "target function timed out");
assert!(err.to_string().contains("call_processor"));
assert!(err.to_string().contains("timed out"));
Source

pub fn parallel_failed( operation_name: impl Into<String>, error_message: impl Into<String>, ) -> DurableError

Create a parallel failed error.

Use when a parallel operation encounters an unrecoverable error.

§Examples
use durable_lambda_core::error::DurableError;

let err = DurableError::parallel_failed("fan_out", "branch 2 panicked");
assert!(err.to_string().contains("fan_out"));
Source

pub fn map_failed( operation_name: impl Into<String>, error_message: impl Into<String>, ) -> DurableError

Create a map failed error.

Use when a map operation encounters an unrecoverable error (e.g., checkpoint failure, task panic). Individual item failures are captured in BatchResult, not as this error.

§Examples
use durable_lambda_core::error::DurableError;

let err = DurableError::map_failed("process_orders", "item 3 panicked");
assert!(err.to_string().contains("process_orders"));
assert!(err.to_string().contains("item 3 panicked"));
Source

pub fn child_context_failed( operation_name: impl Into<String>, error_message: impl Into<String>, ) -> DurableError

Create a child context failed error.

Use when a child context operation fails during execution or is found in a failed state during replay.

§Examples
use durable_lambda_core::error::DurableError;

let err = DurableError::child_context_failed("sub_workflow", "closure returned error");
assert!(err.to_string().contains("sub_workflow"));
assert!(err.to_string().contains("closure returned error"));
Source

pub fn step_timeout(operation_name: impl Into<String>) -> DurableError

Create a step timeout error.

Use when a step closure exceeds the configured timeout_seconds duration.

§Examples
use durable_lambda_core::error::DurableError;

let err = DurableError::step_timeout("my_op");
assert!(err.to_string().contains("my_op"));
assert_eq!(err.code(), "STEP_TIMEOUT");
Source

pub fn compensation_failed( operation_name: impl Into<String>, error_message: impl Into<String>, ) -> DurableError

Create a compensation failed error.

Use when one or more compensation closures in run_compensations() fail. All compensations are attempted even when one fails; this error is returned when the CompensationResult shows failures.

§Examples
use durable_lambda_core::error::DurableError;

let err = DurableError::compensation_failed("charge_payment", "reversal failed");
assert!(err.to_string().contains("charge_payment"));
assert_eq!(err.code(), "COMPENSATION_FAILED");
Source

pub fn code(&self) -> &'static str

Return a stable, programmatic error code for this error variant.

Codes are SCREAMING_SNAKE_CASE and stable across versions. Use these for programmatic error matching instead of parsing display messages.

§Examples
use durable_lambda_core::error::DurableError;

let err = DurableError::replay_mismatch("Step", "Wait", 0);
assert_eq!(err.code(), "REPLAY_MISMATCH");

Trait Implementations§

Source§

impl Debug for DurableError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for DurableError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Error for DurableError

Source§

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

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for DurableError

Source§

fn from(err: Error) -> DurableError

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more