Skip to content

Commit

Permalink
fix: add details to UnknownError
Browse files Browse the repository at this point in the history
  • Loading branch information
therustmonk committed Oct 7, 2021
1 parent ce17627 commit afa18c0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions applications/tari_app_utilities/src/utilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ pub const LOG_TARGET: &str = "tari::application";
pub enum ExitCodes {
#[error("There is an error in the wallet configuration: {0}")]
ConfigError(String),
#[error("The application exited because an unknown error occurred. Check the logs for details.")]
UnknownError,
#[error("The application exited because an unknown error occurred: {0}. Check the logs for more details.")]
UnknownError(String),
#[error("The application exited because an interface error occurred. Check the logs for details.")]
InterfaceError,
#[error("The application exited. {0}")]
Expand Down Expand Up @@ -82,7 +82,7 @@ impl ExitCodes {
pub fn as_i32(&self) -> i32 {
match self {
Self::ConfigError(_) => 101,
Self::UnknownError => 102,
Self::UnknownError(_) => 102,
Self::InterfaceError => 103,
Self::WalletError(_) => 104,
Self::GrpcError(_) => 105,
Expand Down
4 changes: 2 additions & 2 deletions applications/tari_base_node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ fn main_inner() -> Result<(), ExitCodes> {
// Set up the Tokio runtime
let rt = setup_runtime(&node_config).map_err(|e| {
error!(target: LOG_TARGET, "{}", e);
ExitCodes::UnknownError
ExitCodes::UnknownError(e)
})?;

rt.block_on(run_node(node_config.into(), bootstrap))?;
Expand Down Expand Up @@ -227,7 +227,7 @@ async fn run_node(node_config: Arc<GlobalConfig>, bootstrap: ConfigBootstrap) ->
return ExitCodes::ConfigError(boxed_error.to_string());
}
}
ExitCodes::UnknownError
ExitCodes::UnknownError(err.to_string())
})?;

if node_config.grpc_enabled {
Expand Down
7 changes: 4 additions & 3 deletions applications/tari_base_node/src/recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ pub fn initiate_recover_db(node_config: &GlobalConfig) -> Result<(), ExitCodes>
DatabaseType::LMDB(p) => {
let _backend = create_recovery_lmdb_database(&p).map_err(|err| {
error!(target: LOG_TARGET, "{}", err);
ExitCodes::UnknownError
ExitCodes::UnknownError(err.to_string())
})?;
},
_ => {
error!(target: LOG_TARGET, "Recovery mode is only available for LMDB");
return Err(ExitCodes::UnknownError);
const MSG: &str = "Recovery mode is only available for LMDB";
error!(target: LOG_TARGET, "{}", MSG);
return Err(ExitCodes::UnknownError(MSG.to_string()));
},
};
Ok(())
Expand Down

0 comments on commit afa18c0

Please sign in to comment.