Skip to content
Snippets Groups Projects
Commit 1fc6292c authored by dvermd's avatar dvermd
Browse files

[fix] core: #134 remove unwrap

parent aa9a8983
No related branches found
No related tags found
1 merge request!244Resolve "Reliability: remove all "unwrap()" and deny their use"
......@@ -143,7 +143,7 @@ impl DursExecutableCoreCommand for KeysOpt {
match self.subcommand {
KeysSubCommand::Wizard(_) => {
let new_keypairs = key_wizard(keypairs).unwrap();
let new_keypairs = key_wizard(keypairs)?;
save_keypairs(profile_path, &keypairs_file, new_keypairs)
.map_err(DursCoreError::FailWriteKeypairsFile)
}
......
......@@ -17,6 +17,7 @@
use crate::logger::InitLoggerError;
use dubp_currency_params::db::CurrencyParamsDbError;
use durs_conf::keys::WizardError;
use durs_module::{ModuleStaticName, PlugModuleError};
use failure::{Error, Fail};
......@@ -64,6 +65,9 @@ pub enum DursCoreError {
/// Sync without source and without option local
#[fail(display = "Please specify the url of a trusted node or use the --local option.")]
SyncWithoutSource,
/// Error on keys sub-command
#[fail(display = "Error en keys sub-command")]
WizardKeysError(WizardError),
}
impl From<InitLoggerError> for DursCoreError {
......@@ -71,3 +75,9 @@ impl From<InitLoggerError> for DursCoreError {
DursCoreError::InitLoggerError(e)
}
}
impl From<WizardError> for DursCoreError {
fn from(e: WizardError) -> Self {
DursCoreError::WizardKeysError(e)
}
}
......@@ -157,9 +157,8 @@ fn start_broadcasting_thread(
local_node_endpoints.append(&mut module_endpoints);
// If all modules registered
if expected_registrations_count.is_some()
&& registrations_count == expected_registrations_count.unwrap()
{
if let Some(expected_regs_count) = expected_registrations_count {
if registrations_count == expected_regs_count {
// Get list of InterNodesNetwork modules
let receivers = roles
.get(&ModuleRole::InterNodesNetwork)
......@@ -172,6 +171,7 @@ fn start_broadcasting_thread(
&modules_senders,
);
}
}
// Add this sender to modules_senders
modules_senders.insert(module_static_name, module_sender);
}
......@@ -215,8 +215,8 @@ fn start_broadcasting_thread(
RecvTimeoutError::Disconnected => fatal_error!("router thread disconnnected !"),
},
}
if (expected_registrations_count.is_none()
|| registrations_count < expected_registrations_count.unwrap())
if let Some(expected_regs_count) = expected_registrations_count {
if registrations_count < expected_regs_count
&& SystemTime::now()
.duration_since(start_time)
.expect("Duration error !")
......@@ -226,7 +226,13 @@ fn start_broadcasting_thread(
fatal_error!(
"{} modules have registered, but expected {} !",
registrations_count,
expected_registrations_count.unwrap_or(0)
expected_regs_count
);
}
} else {
fatal_error!(
"{} modules have registered, but none expected !",
registrations_count
);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment