summaryrefslogtreecommitdiff
path: root/src/server.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/server.rs')
-rw-r--r--src/server.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/server.rs b/src/server.rs
index 6ea8ac4..3b0584f 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -29,20 +29,20 @@ pub enum ServerConfigError {
#[error("server address can't be resolved")]
BadServerAddress,
- #[error("I/O error for {0}: {1}")]
- IoError(PathBuf, #[source] std::io::Error),
+ #[error("failed to read configuration file {0}: {1}")]
+ Read(PathBuf, std::io::Error),
- #[error(transparent)]
- SerdeYamlError(#[from] serde_yaml::Error),
+ #[error("failed to parse configuration file as YAML: {0}")]
+ YamlParse(serde_yaml::Error),
}
impl ServerConfig {
pub fn read_config(filename: &Path) -> Result<Self, ServerConfigError> {
let config = match std::fs::read_to_string(filename) {
Ok(config) => config,
- Err(err) => return Err(ServerConfigError::IoError(filename.to_path_buf(), err)),
+ Err(err) => return Err(ServerConfigError::Read(filename.to_path_buf(), err)),
};
- let config: Self = serde_yaml::from_str(&config)?;
+ let config: Self = serde_yaml::from_str(&config).map_err(ServerConfigError::YamlParse)?;
config.check()?;
Ok(config)
}