diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-05-06 08:39:14 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-05-06 09:34:28 +0300 |
commit | 2b7160ebdf950ef872f785336fcfe17e0c4cb347 (patch) | |
tree | 216fb5b9c2cf5fa6121e1b2d357508a0c675e3e9 /src/templatespec.rs | |
parent | 6498b2eecb21ad87069be8f501f35374745106d9 (diff) | |
download | subplot-2b7160ebdf950ef872f785336fcfe17e0c4cb347.tar.gz |
refactor! split SubplotError::IoError into more specific errors
Replace SubplotError::IoError with ::Spawn, ::WriteToChild,
::WaitForChild, ::ReadFile, ::CreateFile, ::Writefile.
IoError was a catchall error and as such, so generic that it didn't
help the user to figure out what actually is wrong. For example, there
was no indication what operation was attempted or on what file. The
new error variants are specific.
Sponsored-by: author
Diffstat (limited to 'src/templatespec.rs')
-rw-r--r-- | src/templatespec.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/templatespec.rs b/src/templatespec.rs index dbb39dc..7b8723b 100644 --- a/src/templatespec.rs +++ b/src/templatespec.rs @@ -40,7 +40,8 @@ impl TemplateSpec { /// Read a template.yaml file and create the corresponding TemplateSpec. pub fn from_file(filename: &Path) -> Result<TemplateSpec, SubplotError> { - let yaml = resource::read_as_string(filename, None)?; + let yaml = resource::read_as_string(filename, None) + .map_err(|err| SubplotError::ReadFile(filename.to_path_buf(), err))?; let spec = TemplateSpec::from_yaml(&yaml)?; let dirname = match filename.parent() { Some(x) => x, |