1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//! Configuration-owned project loading and parameter resolution failures.
use std::io;
use std::path::PathBuf;
use thiserror::Error;
/// A failure while compiling project documents into a specification.
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum ConfigError {
/// A required project document could not be read.
#[error("failed to read project document `{path}`")]
Read {
/// Document or directory path involved in the failed operation.
path: PathBuf,
/// Underlying filesystem failure.
#[source]
source: io::Error,
},
/// A project document was not valid JSON.
#[error("failed to parse project document `{path}`")]
Parse {
/// Source document containing invalid JSON.
path: PathBuf,
/// Underlying JSON syntax failure.
#[source]
source: serde_json::Error,
},
/// A JSON object repeated a key.
#[error("project document `{path}` repeats key `{key}`")]
DuplicateKey {
/// Source document containing the duplicate.
path: PathBuf,
/// Repeated object key.
key: String,
},
/// Valid JSON did not satisfy its document grammar.
#[error("invalid project document `{path}` at `{pointer}`: {reason}")]
InvalidDocument {
/// Rejected source document.
path: PathBuf,
/// Nearest meaningful JSON Pointer, or `/` for the root.
pointer: String,
/// Contextual grammar violation.
reason: String,
},
/// A discovered document escaped the project configuration directory.
#[error("document path `{path}` is outside configuration root `{config_root}`")]
PathOutsideConfig {
/// Rejected authored or resolved path.
path: PathBuf,
/// Canonical project configuration root.
config_root: PathBuf,
},
/// A path that must cross a language-neutral JSON boundary is not UTF-8.
#[error("{context} path `{path}` must be valid UTF-8")]
NonUtf8Path {
/// Rejected canonical filesystem path.
path: PathBuf,
/// Stable role the path would have served.
context: &'static str,
},
/// A program or Python task did not resolve to a valid executable, script,
/// or environment.
#[error("invalid program task path `{path}`: {reason}")]
InvalidProgram {
/// Authored program path or command name.
path: PathBuf,
/// Stable resolution or validation failure.
reason: String,
},
/// A phase dependency does not name a declared phase.
#[error("phase `{phase}` depends on unknown phase `{dependency}`")]
UnknownDependency {
/// Referring phase.
phase: String,
/// Missing dependency.
dependency: String,
},
/// An execution-unit task selects no state schema declared by the study.
#[error("execution unit `{execution_unit}` in phase `{phase}` selects unknown state `{state}`")]
UnknownState {
/// Containing phase key.
phase: String,
/// Compiled execution-unit key.
execution_unit: String,
/// Missing state-schema key.
state: String,
},
/// An execution-unit parameter expansion cannot be represented safely.
#[error("execution-unit parameter expansion in `{path}` exceeds supported combination counts")]
ExpansionOverflow {
/// Parameters document whose selection product overflowed.
path: PathBuf,
},
/// One resolved parameter combination could not decode as execution-unit constants.
#[error(
"failed to decode resolved parameter combination {ordinal} for execution unit `{execution_unit}` from `{path}`"
)]
DecodeExecutionUnitConstants {
/// Compiled execution-unit key from the study manifest.
execution_unit: String,
/// Central parameters document path.
path: PathBuf,
/// Zero-based deterministic combination ordinal.
ordinal: u64,
/// Underlying Serde conversion failure.
#[source]
source: serde_json::Error,
},
}
impl ConfigError {
pub(crate) fn invalid(
path: &std::path::Path,
pointer: impl Into<String>,
reason: impl Into<String>,
) -> Self {
Self::InvalidDocument {
path: path.to_path_buf(),
pointer: pointer.into(),
reason: reason.into(),
}
}
}