diff options
Diffstat (limited to 'src/srcdir.rs')
-rw-r--r-- | src/srcdir.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/srcdir.rs b/src/srcdir.rs index 66d2a04..b1a9317 100644 --- a/src/srcdir.rs +++ b/src/srcdir.rs @@ -1,8 +1,13 @@ -use crate::error::SiteError; use log::trace; use std::path::{Path, PathBuf}; use walkdir::WalkDir; +#[derive(Debug, thiserror::Error)] +pub enum SourceDirError { + #[error("failed to list files in source directory: {0}")] + WalkDir(PathBuf, #[source] walkdir::Error), +} + pub struct SourceDir { path: PathBuf, files: Vec<PathBuf>, @@ -31,13 +36,13 @@ impl SourceDir { self.files.push(path.into()); } - pub fn scan(&mut self) -> Result<(), SiteError> { + pub fn scan(&mut self) -> Result<(), SourceDirError> { if self.artificial { trace!("SourceDir::scan: artificial mode, not actually scanning"); } else { trace!("SourceDir::scan: find files in {}", self.path.display()); for e in WalkDir::new(&self.path) { - let e = e.map_err(|err| SiteError::WalkDir(self.path.clone(), err))?; + let e = e.map_err(|err| SourceDirError::WalkDir(self.path.clone(), err))?; let path = e.path(); trace!("SourceDir::scan: found {}", path.display()); self.insert(path); |