Error handling with failure (using Error and ErrorKind) (#713)

* Initial version

* store failure parameters inside ErrorKind variants

* continue failure transformation

* 4 errors left

* still two errors

* return old code back

* finally compiling

* Fix compilation and test errors after merge
This commit is contained in:
Alexey Miroshkin
2018-02-28 18:56:09 +01:00
committed by Antioch Peverell
parent 0d15e22f97
commit 9e11afe8a2
15 changed files with 289 additions and 257 deletions
+23 -21
View File
@@ -515,27 +515,29 @@ fn wallet_command(wallet_args: &ArgMatches, global_config: GlobalConfig) {
dest,
selection_strategy,
),
Err(wallet::Error::NotEnoughFunds(available)) => {
error!(
LOGGER,
"Tx not sent: insufficient funds (max: {})",
amount_to_hr_string(available),
);
}
Err(wallet::Error::FeeExceedsAmount {
sender_amount,
recipient_fee,
}) => {
error!(
LOGGER,
"Recipient rejected the transfer because transaction fee ({}) exceeded amount ({}).",
amount_to_hr_string(recipient_fee),
amount_to_hr_string(sender_amount)
);
}
Err(e) => {
error!(LOGGER, "Tx not sent: {:?}", e);
}
Err(e) => match e.kind() {
wallet::ErrorKind::NotEnoughFunds(available) => {
error!(
LOGGER,
"Tx not sent: insufficient funds (max: {})",
amount_to_hr_string(available),
);
}
wallet::ErrorKind::FeeExceedsAmount {
sender_amount,
recipient_fee,
} => {
error!(
LOGGER,
"Recipient rejected the transfer because transaction fee ({}) exceeded amount ({}).",
amount_to_hr_string(recipient_fee),
amount_to_hr_string(sender_amount)
);
}
_ => {
error!(LOGGER, "Tx not sent: {:?}", e);
}
}
};
}
("burn", Some(send_args)) => {