scientific_workflow/study/
error.rs1use thiserror::Error;
4
5use crate::config::advanced::ConfigError;
6use crate::state::advanced::StateError;
7use crate::task::advanced::ModelCatalogError;
8
9#[derive(Debug, Error)]
11#[non_exhaustive]
12pub enum StudyError {
13 #[error("failed to load project declarations")]
15 Config(#[from] ConfigError),
16
17 #[error("failed to validate the project state schema")]
19 State(#[from] StateError),
20
21 #[error("invalid compiled model registration: {reason}")]
23 InvalidModelRegistration {
24 reason: String,
26 },
27
28 #[error("phase `{phase}` references unregistered model `{model}`")]
30 UnknownModel {
31 phase: String,
33 model: String,
35 },
36
37 #[error(
39 "model `{model}` failed preflight for resolved parameters {ordinal} in phase `{phase}`"
40 )]
41 ModelPreflight {
42 phase: String,
44 model: String,
46 ordinal: u64,
48 #[source]
50 source: Box<dyn std::error::Error + Send + Sync + 'static>,
51 },
52
53 #[error("the study contains more expanded task invocations than can be identified")]
55 TaskIdentityOverflow,
56}
57
58impl From<ModelCatalogError> for StudyError {
59 fn from(source: ModelCatalogError) -> Self {
60 Self::InvalidModelRegistration {
61 reason: source.to_string(),
62 }
63 }
64}
65
66impl StudyError {
67 pub(crate) fn model_preflight(
68 phase: &str,
69 model: &str,
70 ordinal: u64,
71 source: Box<dyn std::error::Error + Send + Sync + 'static>,
72 ) -> Self {
73 Self::ModelPreflight {
74 phase: phase.to_owned(),
75 model: model.to_owned(),
76 ordinal,
77 source,
78 }
79 }
80}