summaryrefslogtreecommitdiff
path: root/src/spec.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-03-25 09:37:15 +0000
committerLars Wirzenius <liw@liw.fi>2021-03-25 09:37:15 +0000
commita45450a42e4cdcd7f2d5671984c9c7f3945131fd (patch)
tree27e9b77e04a877a3efdb7b9795f5977060b3488a /src/spec.rs
parent8e6febfb777714c5b7f5ed9843e660ef218d3eb0 (diff)
parent23138e5bdb8ca751834009d99d85b37e5e4ae5ae (diff)
downloadvmadm-a45450a42e4cdcd7f2d5671984c9c7f3945131fd.tar.gz
Merge branch 'errors' into 'main'
subplot fix and error message improvements Closes #14 See merge request larswirzenius/vmadm!29
Diffstat (limited to 'src/spec.rs')
-rw-r--r--src/spec.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/spec.rs b/src/spec.rs
index b9828e9..a1d1c2f 100644
--- a/src/spec.rs
+++ b/src/spec.rs
@@ -216,14 +216,14 @@ pub enum SpecificationError {
#[error("No SSH authorized keys specified for {0} and no default configured")]
NoAuthorizedKeys(String),
+ /// Error reading specification file.
+ #[error("Couldn't read specification file {0}")]
+ Read(PathBuf, #[source] std::io::Error),
+
/// Error reading SSH public key.
#[error("Failed to read SSH public key file {0}")]
SshKeyRead(PathBuf, #[source] std::io::Error),
- /// I/O error.
- #[error(transparent)]
- IoError(#[from] std::io::Error),
-
/// Error parsing string as UTF8.
#[error(transparent)]
FromUtf8Error(#[from] std::string::FromUtf8Error),
@@ -247,7 +247,8 @@ impl Specification {
filename: &Path,
) -> Result<Vec<Specification>, SpecificationError> {
debug!("reading specification from {}", filename.display());
- let spec = fs::read(filename)?;
+ let spec = fs::read(filename)
+ .map_err(|err| SpecificationError::Read(filename.to_path_buf(), err))?;
let input: HashMap<String, OneVmInputSpecification> = serde_yaml::from_slice(&spec)?;
debug!("specification as read from file: {:#?}", input);