From dbc266182ba9a043f52987e7d75937f3f42c753d Mon Sep 17 00:00:00 2001 From: Kirill Lykov Date: Mon, 20 Jun 2022 19:44:45 +0100 Subject: [PATCH] improve error reporting in get_account --- bench-tps/src/bench_tps_client/bank_client.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/bench-tps/src/bench_tps_client/bank_client.rs b/bench-tps/src/bench_tps_client/bank_client.rs index 77fae84c4a80c7..9fae1f7a93c7f6 100644 --- a/bench-tps/src/bench_tps_client/bank_client.rs +++ b/bench-tps/src/bench_tps_client/bank_client.rs @@ -85,14 +85,12 @@ impl BenchTpsClient for BankClient { } fn get_account(&self, pubkey: &Pubkey) -> Result { - let account = SyncClient::get_account(self, pubkey).map_err(|err| err.into()); - if let Ok(account) = account { - if account.is_none() { - return Err(BenchTpsError::Custom("Account was not found".to_string())); - } - Ok(account.unwrap()) - } else { - Err(account.err().unwrap()) - } + SyncClient::get_account(self, pubkey) + .map_err(|err| err.into()) + .and_then(|account| { + account.ok_or_else(|| { + BenchTpsError::Custom(format!("AccountNotFound: pubkey={}", pubkey)) + }) + }) } }