diff options
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/config.rs b/src/config.rs index 88c186b..1866971 100644 --- a/src/config.rs +++ b/src/config.rs @@ -41,9 +41,9 @@ pub struct Configuration { /// Errors from this module. #[derive(Debug, thiserror::Error)] pub enum ConfigurationError { - /// I/O error. - #[error(transparent)] - IoError(#[from] std::io::Error), + /// Error reading configuration file. + #[error("couldn't read configuration file {0}")] + ReadError(PathBuf, #[source] std::io::Error), /// YAML parsing error. #[error(transparent)] @@ -55,7 +55,8 @@ impl Configuration { pub fn from_file(filename: &Path) -> Result<Self, ConfigurationError> { if filename.exists() { debug!("reading configuration file {}", filename.display()); - let config = fs::read(filename)?; + let config = fs::read(filename) + .map_err(|err| ConfigurationError::ReadError(filename.to_path_buf(), err))?; let config: Configuration = serde_yaml::from_slice(&config)?; debug!("config: {:#?}", config); Ok(config) |