Files
wfe/wfe-core/src/models/execution_error.rs
Sienna Meridian Satterwhite d87d888787 feat(wfe-core): add models, traits, and error types
Core domain models: WorkflowInstance, ExecutionPointer, WorkflowDefinition,
WorkflowStep, Event, EventSubscription, ScheduledCommand, ExecutionError,
LifecycleEvent, PollEndpointConfig. All serde-serializable.

Provider traits: PersistenceProvider (composite of WorkflowRepository,
EventRepository, SubscriptionRepository, ScheduledCommandRepository),
DistributedLockProvider, QueueProvider, SearchIndex, LifecyclePublisher,
WorkflowMiddleware, StepMiddleware, WorkflowRegistry.

StepBody trait with StepExecutionContext for workflow step implementations.
WorkflowData marker trait (blanket impl for Serialize + DeserializeOwned).
2026-03-25 20:07:50 +00:00

49 lines
1.4 KiB
Rust

use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ExecutionError {
pub error_time: DateTime<Utc>,
pub workflow_id: String,
pub execution_pointer_id: String,
pub message: String,
}
impl ExecutionError {
pub fn new(
workflow_id: impl Into<String>,
execution_pointer_id: impl Into<String>,
message: impl Into<String>,
) -> Self {
Self {
error_time: Utc::now(),
workflow_id: workflow_id.into(),
execution_pointer_id: execution_pointer_id.into(),
message: message.into(),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use pretty_assertions::assert_eq;
#[test]
fn new_error_captures_fields() {
let err = ExecutionError::new("wf-1", "ptr-1", "something went wrong");
assert_eq!(err.workflow_id, "wf-1");
assert_eq!(err.execution_pointer_id, "ptr-1");
assert_eq!(err.message, "something went wrong");
}
#[test]
fn serde_round_trip() {
let err = ExecutionError::new("wf-1", "ptr-1", "fail");
let json = serde_json::to_string(&err).unwrap();
let deserialized: ExecutionError = serde_json::from_str(&json).unwrap();
assert_eq!(err.workflow_id, deserialized.workflow_id);
assert_eq!(err.message, deserialized.message);
}
}