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
// ---
// relationships:
// implements: intent-driven-polyglot-release
// ---
//! Error types shared by core operations.
use std::path::PathBuf;
/// Core operation result.
pub type Result<T> = std::result::Result<T, Error>;
/// Errors produced by `intentional-core`.
#[derive(Debug, thiserror::Error)]
pub enum Error {
/// The configuration uses `contract-1`, which only `intentional init` loads.
#[error(
".intentional/config.yml uses contract-1, which this version of intentional does not load; run `intentional init` to upgrade it to contract-2"
)]
ContractUpgradeRequired,
/// A configuration or intent is invalid.
#[error("validation failed: {0}")]
Validation(String),
/// A required file could not be read or written.
#[error("failed to access {path}: {source}")]
Io {
/// File involved in the operation.
path: PathBuf,
/// Underlying filesystem error.
source: std::io::Error,
},
/// YAML could not be parsed or serialized.
#[error("invalid YAML: {0}")]
Yaml(#[from] serde_yaml::Error),
/// Git state could not be discovered or traversed.
#[error("git operation failed: {0}")]
Git(String),
/// A semantic version could not be represented.
#[error("invalid semantic version: {0}")]
Semver(#[from] semver::Error),
}
impl Error {
/// Attach a path to an I/O error.
pub(crate) fn io(path: impl Into<PathBuf>, source: std::io::Error) -> Self {
Self::Io {
path: path.into(),
source,
}
}
}