Skip to content

Commit

Permalink
improve error reporting in get_account
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill Lykov committed Jun 20, 2022
1 parent 63c6740 commit dbc2661
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions bench-tps/src/bench_tps_client/bank_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,12 @@ impl BenchTpsClient for BankClient {
}

fn get_account(&self, pubkey: &Pubkey) -> Result<Account> {
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))
})
})
}
}

0 comments on commit dbc2661

Please sign in to comment.