Skip to content

Commit

Permalink
added debug log and new custom error for non existing config file
Browse files Browse the repository at this point in the history
  • Loading branch information
jl-animo committed Mar 14, 2022
1 parent ee3447f commit e89ef43
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
2 changes: 2 additions & 0 deletions cli/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::fmt::{Display, Formatter};

#[derive(Debug)]
pub enum Error {
CannotReadConfigurationFile,
InvalidConfigurationPath,
InvalidConfigurationStructure,
InvalidEnvironment,
Expand All @@ -21,6 +22,7 @@ pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Error::CannotReadConfigurationFile => write!(f, "Cannot not read configuration file. Try initializing configuration first."),
Error::InvalidConfigurationPath => write!(f, "Invalid configuration path."),
Error::InvalidEnvironment => write!(f, "Invalid environment."),
Error::NoEndpointSupplied => write!(f, "No endpoint supplied. Supply an endpoint either via `--endpoint` or via `--config`."),
Expand Down
14 changes: 4 additions & 10 deletions cli/src/modules/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,10 @@ pub async fn parse_configuration_args(options: &ConfigurationOptions) -> Result<
String::from(config_path.to_str().unwrap()).bold()
);

let _ = match view(&config_path) {
Ok(config) => config,
Err(e) => {
error!(
"Cannot not read configuration file. Try initializing configuration first."
);
return Err(e);
}
};
return Ok(());
view(&config_path).map_err(|err| {
debug!("Failed to read config file: {}", err);
return error::Error::CannotReadConfigurationFile.into();
})
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion cli/src/modules/credential_definition.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use agent::modules::credential_definition::CredentialDefinitionModule;
use clap::{Args, Subcommand};
use colored::*;
use log:{debug, info};
use log::{debug, info};
use serde_json::json;

use crate::{
Expand Down

0 comments on commit e89ef43

Please sign in to comment.