scientific_workflow/study/
error.rs1use std::path::{Path, PathBuf};
4
5use thiserror::Error;
6
7use crate::config::ConfigError;
8use crate::state::StateError;
9use crate::task::ExecutionUnitCatalogError;
10
11#[derive(Debug, Error)]
13#[non_exhaustive]
14pub enum StudyError {
15 #[error("failed to load project declarations")]
17 Config(#[from] ConfigError),
18
19 #[error("failed to validate state schema `{state}` from `{path}`")]
21 State {
22 state: String,
24 path: PathBuf,
26 #[source]
28 source: StateError,
29 },
30
31 #[error("failed to validate standard state-schema provider `{provider}`")]
33 ProvidedState {
34 provider: String,
36 #[source]
38 source: StateError,
39 },
40
41 #[error("invalid standard state-schema provider `{provider}`: {reason}")]
43 InvalidStateSchemaProvider {
44 provider: String,
46 reason: String,
48 },
49
50 #[error("invalid compiled execution-unit registration: {reason}")]
52 InvalidExecutionUnitRegistration {
53 reason: String,
55 },
56
57 #[error("phase `{phase}` references unregistered execution unit `{execution_unit}`")]
59 UnknownExecutionUnit {
60 phase: String,
62 execution_unit: String,
64 },
65
66 #[error(
69 "execution unit `{execution_unit}` in phase `{phase}` does not declare thread-count-invariant execution required by automatic compute allocation"
70 )]
71 AutoComputeRequiresInvariantUnit {
72 phase: String,
74 execution_unit: String,
76 },
77
78 #[error(
80 "execution unit `{execution_unit}` in phase `{phase}` requires an explicit project state because it has no standard state-schema provider"
81 )]
82 MissingStateSchema {
83 phase: String,
85 execution_unit: String,
87 },
88
89 #[error(
91 "execution unit `{execution_unit}` failed preflight for resolved parameters {ordinal} in phase `{phase}`"
92 )]
93 ExecutionUnitPreflight {
94 phase: String,
96 execution_unit: String,
98 ordinal: u64,
100 #[source]
102 source: Box<dyn std::error::Error + Send + Sync + 'static>,
103 },
104
105 #[error("the study contains more expanded task invocations than can be identified")]
107 TaskIdentityOverflow,
108}
109
110impl From<ExecutionUnitCatalogError> for StudyError {
111 fn from(source: ExecutionUnitCatalogError) -> Self {
112 Self::InvalidExecutionUnitRegistration {
113 reason: source.to_string(),
114 }
115 }
116}
117
118impl StudyError {
119 pub(crate) fn state_schema(state: &str, path: &Path, source: StateError) -> Self {
120 Self::State {
121 state: state.to_owned(),
122 path: path.to_path_buf(),
123 source,
124 }
125 }
126
127 pub(crate) fn execution_unit_preflight(
128 phase: &str,
129 execution_unit: &str,
130 ordinal: u64,
131 source: Box<dyn std::error::Error + Send + Sync + 'static>,
132 ) -> Self {
133 Self::ExecutionUnitPreflight {
134 phase: phase.to_owned(),
135 execution_unit: execution_unit.to_owned(),
136 ordinal,
137 source,
138 }
139 }
140}