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("invalid compiled execution-unit registration: {reason}")]
33 InvalidExecutionUnitRegistration {
34 reason: String,
36 },
37
38 #[error("phase `{phase}` references unregistered execution unit `{execution_unit}`")]
40 UnknownExecutionUnit {
41 phase: String,
43 execution_unit: String,
45 },
46
47 #[error(
49 "execution unit `{execution_unit}` failed preflight for resolved parameters {ordinal} in phase `{phase}`"
50 )]
51 ExecutionUnitPreflight {
52 phase: String,
54 execution_unit: String,
56 ordinal: u64,
58 #[source]
60 source: Box<dyn std::error::Error + Send + Sync + 'static>,
61 },
62
63 #[error("the study contains more expanded task invocations than can be identified")]
65 TaskIdentityOverflow,
66}
67
68impl From<ExecutionUnitCatalogError> for StudyError {
69 fn from(source: ExecutionUnitCatalogError) -> Self {
70 Self::InvalidExecutionUnitRegistration {
71 reason: source.to_string(),
72 }
73 }
74}
75
76impl StudyError {
77 pub(crate) fn state_schema(state: &str, path: &Path, source: StateError) -> Self {
78 Self::State {
79 state: state.to_owned(),
80 path: path.to_path_buf(),
81 source,
82 }
83 }
84
85 pub(crate) fn execution_unit_preflight(
86 phase: &str,
87 execution_unit: &str,
88 ordinal: u64,
89 source: Box<dyn std::error::Error + Send + Sync + 'static>,
90 ) -> Self {
91 Self::ExecutionUnitPreflight {
92 phase: phase.to_owned(),
93 execution_unit: execution_unit.to_owned(),
94 ordinal,
95 source,
96 }
97 }
98}