Improve CLI error messages

This commit is contained in:
Paul Hauner 2019-08-26 15:57:40 +10:00
parent bab1f2b064
commit 39be2ed1d2
No known key found for this signature in database
GPG Key ID: 5E2CFF9B75FA63DF

View File

@ -366,9 +366,9 @@ impl<'a> ConfigBuilder<'a> {
///
/// Returns an error if any files are not found or are invalid.
pub fn load_client_config(&mut self, path: PathBuf) -> Result<()> {
self.client_config = read_from_file::<ClientConfig>(path)
.map_err(|e| format!("Unable to parse ClientConfig file: {:?}", e))?
.ok_or_else(|| "ClientConfig file does not exist".to_string())?;
self.client_config = read_from_file::<ClientConfig>(path.clone())
.map_err(|e| format!("Unable to parse {:?} file: {:?}", path, e))?
.ok_or_else(|| format!("{:?} file does not exist", path))?;
Ok(())
}
@ -377,9 +377,9 @@ impl<'a> ConfigBuilder<'a> {
///
/// Returns an error if any files are not found or are invalid.
pub fn load_eth2_config(&mut self, path: PathBuf) -> Result<()> {
self.eth2_config = read_from_file::<Eth2Config>(path)
.map_err(|e| format!("Unable to parse Eth2Config file: {:?}", e))?
.ok_or_else(|| "Eth2Config file does not exist".to_string())?;
self.eth2_config = read_from_file::<Eth2Config>(path.clone())
.map_err(|e| format!("Unable to parse {:?} file: {:?}", path, e))?
.ok_or_else(|| format!("{:?} file does not exist", path))?;
Ok(())
}