1use anyhow::Error as AnyhowError;
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum OrkaError {
7 #[error("Step not found: {step_name}")]
8 StepNotFound { step_name: String },
9
10 #[error("Handler missing for non-optional step: {step_name}")]
11 HandlerMissing { step_name: String },
12
13 #[error("Extractor failed for step '{step_name}'. Source: {source}")]
14 ExtractorFailure {
15 step_name: String,
16 #[source]
17 source: AnyhowError,
18 },
19
20 #[error("Pipeline provider failed for conditional scope in step '{step_name}'. Source: {source}")]
21 PipelineProviderFailure {
22 step_name: String,
23 #[source]
24 source: AnyhowError,
25 },
26
27 #[error("Type mismatch during context downcast (expected {expected_type}, step: '{step_name}')")]
28 TypeMismatch {
29 step_name: String,
30 expected_type: String,
31 },
32
33 #[error("Error in user-provided handler or external operation. Source: {source}")]
34 HandlerError {
35 #[source]
36 source: AnyhowError,
37 },
38
39 #[error("Configuration error for step '{step_name}': {message}")]
40 ConfigurationError { step_name: String, message: String },
41
42 #[error("Internal Orka error: {0}")]
43 Internal(String),
44 #[error("No conditional scope's condition matched for step '{step_name}'")]
46 NoConditionalScopeMatched { step_name: String },
47}
48
49impl From<AnyhowError> for OrkaError {
51 fn from(err: AnyhowError) -> Self {
52 if let Some(orka_err) = err.downcast_ref::<OrkaError>() {
55 return OrkaError::HandlerError { source: err };
65 }
66 OrkaError::HandlerError { source: err }
67 }
68}
69
70pub type OrkaResult<T, E = OrkaError> = std::result::Result<T, E>;