SagaExecutionError

data class SagaExecutionError(val step: TypedValue, val phase: SagaExecutionError.Phase, val exception: Throwable, val timestamp: Long = System.currentTimeMillis())

Error that occurred during saga execution or compensation.

This class captures detailed information about failures during saga execution, including the step identifier, phase (forward or compensation), and the underlying exception. The step is wrapped in TypedValue to preserve enum type information when enum step names are used.

Usage Example

enum class OrderSteps { VALIDATE, PAYMENT, SHIP }

when (result) {
is SagaResult.Aborted -> {
val error = result.error
// Type-safe enum access
when (error.stepAs<OrderSteps>()) {
OrderSteps.PAYMENT -> handlePaymentFailure(error.exception)
else -> log.error("Step '${error.stepName}' failed: ${error.message}")
}
}
}

Constructors

Link copied to clipboard
constructor(step: TypedValue, phase: SagaExecutionError.Phase, exception: Throwable, timestamp: Long = System.currentTimeMillis())

Types

Link copied to clipboard

Execution phase where the error occurred.

Properties

Link copied to clipboard

The underlying exception that caused the failure

Link copied to clipboard

Human-readable error message combining step name, phase, and exception message.

Link copied to clipboard

The execution phase where the error occurred (FORWARD or COMPENSATION)

Link copied to clipboard

The step identifier wrapped in TypedValue

Link copied to clipboard

String representation of the step name. Provided for backward compatibility.

Link copied to clipboard

Timestamp when the error occurred (milliseconds since epoch)

Functions

Link copied to clipboard
inline fun <E : Enum<E>> stepAs(): E?

Retrieves the step identifier as the specified enum type.