summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/subplot.rs5
-rw-r--r--src/error.rs8
2 files changed, 12 insertions, 1 deletions
diff --git a/src/bin/subplot.rs b/src/bin/subplot.rs
index 907e616..a85ad62 100644
--- a/src/bin/subplot.rs
+++ b/src/bin/subplot.rs
@@ -308,7 +308,10 @@ impl Docgen {
}
fn mtime(filename: &Path) -> Result<(u64, u32)> {
- let mtime = fs::metadata(filename)?.modified()?;
+ let mtime = fs::metadata(filename)
+ .map_err(|e| SubplotError::InputFileUnreadable(filename.into(), e))?
+ .modified()
+ .map_err(|e| SubplotError::InputFileMtime(filename.into(), e))?;
let mtime = mtime.duration_since(UNIX_EPOCH)?;
Ok((mtime.as_secs(), mtime.subsec_nanos()))
}
diff --git a/src/error.rs b/src/error.rs
index 53eccad..a729bf0 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -321,6 +321,14 @@ pub enum SubplotError {
/// String formatting failed.
#[error("Failed in string formattiing: {0}")]
StringFormat(std::fmt::Error),
+
+ /// Input file could not be read.
+ #[error("Failed to read input file {0}")]
+ InputFileUnreadable(PathBuf, #[source] std::io::Error),
+
+ /// Input file mtime lookup.
+ #[error("Failed to get modification time of {0}")]
+ InputFileMtime(PathBuf, #[source] std::io::Error),
}
impl SubplotError {