From 2b7160ebdf950ef872f785336fcfe17e0c4cb347 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 6 May 2022 08:39:14 +0300 Subject: 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 --- src/templatespec.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/templatespec.rs') 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 { - 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, -- cgit v1.2.1