summaryrefslogtreecommitdiff
path: root/src/doc.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-05-06 08:39:14 +0300
committerLars Wirzenius <liw@liw.fi>2022-05-06 09:34:28 +0300
commit2b7160ebdf950ef872f785336fcfe17e0c4cb347 (patch)
tree216fb5b9c2cf5fa6121e1b2d357508a0c675e3e9 /src/doc.rs
parent6498b2eecb21ad87069be8f501f35374745106d9 (diff)
downloadsubplot-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/doc.rs')
-rw-r--r--src/doc.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/doc.rs b/src/doc.rs
index e65aff5..37f32d6 100644
--- a/src/doc.rs
+++ b/src/doc.rs
@@ -204,7 +204,8 @@ impl<'a> Document {
) -> Result<Document, SubplotError> {
trace!("Parsing document with pullmark-cmark from {:?}", filename);
let filename = filename.to_path_buf();
- let markdown = std::fs::read_to_string(&filename)?;
+ let markdown = std::fs::read_to_string(&filename)
+ .map_err(|err| SubplotError::ReadFile(filename.clone(), err))?;
let ast = ast::AbstractSyntaxTree::from_str(&markdown)?;
trace!("Parsed document OK");