use std::io;
use std::path::PathBuf;
use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum ConfigurationError {
#[error("failed to read project configuration file `{path}`")]
ReadConfigurationFile {
path: PathBuf,
#[source]
source: io::Error,
},
#[error("failed to parse project configuration file `{path}`")]
ParseConfigurationFile {
path: PathBuf,
#[source]
source: serde_json::Error,
},
#[error("invalid project configuration in `{path}`: {reason}")]
InvalidConfigurationDocument {
path: PathBuf,
reason: String,
},
#[error("project configuration file `{path}` repeats key `{key}`")]
DuplicateConfigurationKey {
path: PathBuf,
key: String,
},
#[error(
"parameter `{key}` appears in both fixed configuration `{fixed_path}` and sweep configuration `{sweep_path}`"
)]
FixedSweepKeyConflict {
key: String,
fixed_path: PathBuf,
sweep_path: PathBuf,
},
#[error("parameter sweep task count overflows u64 while adding axis `{axis}`")]
TaskCountOverflow {
axis: String,
},
#[error(
"task ordinal {ordinal} is out of bounds for a parameter space containing {task_count} tasks"
)]
TaskOrdinalOutOfBounds {
ordinal: u64,
task_count: u64,
},
#[error("task selection key `{key}` is not declared by sweep.json")]
UnknownSweepParameter {
key: String,
},
#[error("failed to encode task selection value for sweep parameter `{key}`")]
EncodeTaskSelection {
key: String,
#[source]
source: serde_json::Error,
},
#[error("no task configuration matches sweep parameter `{key}`")]
NoMatchingTaskConfiguration {
key: String,
},
#[error("more than one task configuration matches sweep parameter `{key}`")]
AmbiguousTaskConfiguration {
key: String,
},
#[error("task ordinal {task_ordinal} does not contain parameter `{key}`")]
UnknownTaskParameter {
task_ordinal: u64,
key: String,
},
#[error("failed to decode parameter `{key}` from task ordinal {task_ordinal}")]
DecodeTaskParameter {
task_ordinal: u64,
key: String,
#[source]
source: serde_json::Error,
},
#[error("failed to serialize resolved parameters for task ordinal {task_ordinal}")]
SerializeTaskParameters {
task_ordinal: u64,
#[source]
source: serde_json::Error,
},
#[error("project paths do not contain key `{key}`")]
UnknownProjectPath {
key: String,
},
#[error("failed to write project configuration file `{path}`")]
WriteConfigurationFile {
path: PathBuf,
#[source]
source: io::Error,
},
}