Skip to main content

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 resolving `fixed.json` and `sweep.json`.
9#[derive(Debug, Error)]
10#[non_exhaustive]
11pub enum ConfigurationError {
12    #[error("failed to read configuration file `{path}`")]
13    ReadConfigurationFile {
14        path: PathBuf,
15        #[source]
16        source: io::Error,
17    },
18
19    #[error("failed to parse configuration file `{path}`")]
20    ParseConfigurationFile {
21        path: PathBuf,
22        #[source]
23        source: serde_json::Error,
24    },
25
26    #[error("invalid configuration in `{path}`: {reason}")]
27    InvalidConfigurationDocument { path: PathBuf, reason: String },
28
29    #[error("configuration file `{path}` repeats key `{key}`")]
30    DuplicateConfigurationKey { path: PathBuf, key: String },
31
32    #[error(
33        "parameter `{key}` appears in both fixed configuration `{fixed_path}` and sweep configuration `{sweep_path}`"
34    )]
35    FixedSweepKeyConflict {
36        key: String,
37        fixed_path: PathBuf,
38        sweep_path: PathBuf,
39    },
40
41    #[error("configuration combination count overflows u64 while adding axis `{axis}`")]
42    CombinationCountOverflow { axis: String },
43
44    #[error(
45        "combination ordinal {ordinal} is out of bounds for a configuration space containing {combination_count} combinations"
46    )]
47    CombinationOrdinalOutOfBounds {
48        ordinal: u64,
49        combination_count: u64,
50    },
51
52    #[error("configuration ordinal {ordinal} does not contain value `{key}`")]
53    UnknownConfigurationValue { ordinal: u64, key: String },
54
55    #[error("failed to decode value `{key}` from configuration ordinal {ordinal}")]
56    DecodeConfigurationValue {
57        ordinal: u64,
58        key: String,
59        #[source]
60        source: serde_json::Error,
61    },
62
63    #[error("project paths do not contain `{key}`")]
64    UnknownProjectPath { key: String },
65
66    #[error("failed to serialize resolved configuration ordinal {ordinal}")]
67    SerializeResolvedConfiguration {
68        ordinal: u64,
69        #[source]
70        source: serde_json::Error,
71    },
72}