ricecoder_execution/
error.rs

1//! Error types for execution module
2
3use thiserror::Error;
4
5/// Errors that can occur during execution planning and execution
6#[derive(Debug, Error)]
7pub enum ExecutionError {
8    /// Plan building failed
9    #[error("Plan building failed: {0}")]
10    PlanError(String),
11
12    /// Step execution failed
13    #[error("Step failed: {0}")]
14    StepFailed(String),
15
16    /// Tests failed with specified number of failures
17    #[error("Tests failed: {0} failures")]
18    TestsFailed(usize),
19
20    /// Rollback failed
21    #[error("Rollback failed: {0}")]
22    RollbackFailed(String),
23
24    /// Approval was denied
25    #[error("Approval denied")]
26    ApprovalDenied,
27
28    /// Validation error
29    #[error("Validation error: {0}")]
30    ValidationError(String),
31
32    /// Configuration error
33    #[error("Configuration error: {0}")]
34    ConfigError(String),
35
36    /// IO error
37    #[error("IO error: {0}")]
38    IoError(#[from] std::io::Error),
39
40    /// Serialization error
41    #[error("Serialization error: {0}")]
42    SerializationError(String),
43
44    /// Timeout error
45    #[error("Timeout after {0}ms")]
46    Timeout(u64),
47
48    /// State persistence error
49    #[error("State persistence error: {0}")]
50    StatePersistenceError(String),
51}
52
53impl PartialEq for ExecutionError {
54    fn eq(&self, other: &Self) -> bool {
55        match (self, other) {
56            (ExecutionError::PlanError(a), ExecutionError::PlanError(b)) => a == b,
57            (ExecutionError::StepFailed(a), ExecutionError::StepFailed(b)) => a == b,
58            (ExecutionError::TestsFailed(a), ExecutionError::TestsFailed(b)) => a == b,
59            (ExecutionError::RollbackFailed(a), ExecutionError::RollbackFailed(b)) => a == b,
60            (ExecutionError::ApprovalDenied, ExecutionError::ApprovalDenied) => true,
61            (ExecutionError::ValidationError(a), ExecutionError::ValidationError(b)) => a == b,
62            (ExecutionError::ConfigError(a), ExecutionError::ConfigError(b)) => a == b,
63            (ExecutionError::SerializationError(a), ExecutionError::SerializationError(b)) => {
64                a == b
65            }
66            (ExecutionError::Timeout(a), ExecutionError::Timeout(b)) => a == b,
67            (
68                ExecutionError::StatePersistenceError(a),
69                ExecutionError::StatePersistenceError(b),
70            ) => a == b,
71            // IoError comparison: compare error kinds
72            (ExecutionError::IoError(a), ExecutionError::IoError(b)) => a.kind() == b.kind(),
73            _ => false,
74        }
75    }
76}
77
78/// Result type for execution operations
79pub type ExecutionResult<T> = Result<T, ExecutionError>;