scientific_workflow/configuration/error.rs
1//! Errors produced while loading, expanding, and inspecting configuration.
2
3use std::io;
4use std::path::PathBuf;
5
6use thiserror::Error;
7
8/// A failure encountered while loading study settings, paths, or parameters.
9#[derive(Debug, Error)]
10#[non_exhaustive]
11pub enum ConfigurationError {
12 /// A configuration source could not be read from the filesystem.
13 #[error("failed to read configuration file `{path}`")]
14 ReadConfigurationFile {
15 /// Source path that could not be read.
16 path: PathBuf,
17 /// Underlying filesystem failure.
18 #[source]
19 source: io::Error,
20 },
21
22 /// A source file was not valid JSON.
23 #[error("failed to parse configuration file `{path}`")]
24 ParseConfigurationFile {
25 /// Source path containing invalid JSON.
26 path: PathBuf,
27 /// Underlying JSON syntax failure.
28 #[source]
29 source: serde_json::Error,
30 },
31
32 /// Valid JSON did not conform to the configuration grammar.
33 #[error("invalid configuration in `{path}`: {reason}")]
34 InvalidConfigurationDocument {
35 /// Rejected source path.
36 path: PathBuf,
37 /// Contextual grammar violation.
38 reason: String,
39 },
40
41 /// A JSON object repeated a key that would otherwise be overwritten.
42 #[error("configuration file `{path}` repeats key `{key}`")]
43 DuplicateConfigurationKey {
44 /// Source path containing the duplicate.
45 path: PathBuf,
46 /// Repeated JSON object key.
47 key: String,
48 },
49
50 /// A requested component-qualified workload is not declared.
51 #[error("study configuration has no workload `{component}/{workload}`")]
52 UnknownWorkloadConfiguration {
53 /// Requested component key.
54 component: String,
55 /// Requested workload key.
56 workload: String,
57 },
58
59 /// The Cartesian product cannot be represented by a `u64` ordinal.
60 #[error("configuration combination count overflows u64 while adding axis `{axis}`")]
61 CombinationCountOverflow {
62 /// Sweep axis or phase composition that caused the overflow.
63 axis: String,
64 },
65
66 /// A requested flattened ordinal is outside its workload configuration.
67 #[error(
68 "combination ordinal {ordinal} is out of bounds for a configuration space containing {combination_count} combinations"
69 )]
70 CombinationOrdinalOutOfBounds {
71 /// Requested zero-based ordinal.
72 ordinal: u64,
73 /// Number of valid combinations in the workload.
74 combination_count: u64,
75 },
76
77 /// A resolved configuration does not contain a requested JSON Pointer.
78 #[error("configuration ordinal {ordinal} does not contain value `{key}`")]
79 UnknownConfigurationValue {
80 /// Flattened combination ordinal being inspected.
81 ordinal: u64,
82 /// Missing canonical JSON Pointer.
83 key: String,
84 },
85
86 /// A present configuration value could not be decoded as the requested type.
87 #[error("failed to decode value `{key}` from configuration ordinal {ordinal}")]
88 DecodeConfigurationValue {
89 /// Flattened combination ordinal being decoded.
90 ordinal: u64,
91 /// Canonical JSON Pointer of the value.
92 key: String,
93 /// Underlying Serde conversion failure.
94 #[source]
95 source: serde_json::Error,
96 },
97
98 /// The named project-path table does not contain a requested key.
99 #[error("project paths do not contain `{key}`")]
100 UnknownProjectPath {
101 /// Missing project-path key.
102 key: String,
103 },
104}