Skip to content

Commit

Permalink
More informative error (#2991)
Browse files Browse the repository at this point in the history
  • Loading branch information
scx1332 authored Jan 16, 2024
1 parent edb8a68 commit 800884b
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions core/payment/src/accounts.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use anyhow::anyhow;
use serde::{Deserialize, Serialize};
use ya_core_model::driver::{driver_bus_id, AccountMode, Init};
use ya_service_bus::typed as bus;
Expand All @@ -19,14 +20,34 @@ pub(crate) async fn init_account(account: Account) -> anyhow::Result<()> {
let mut mode = AccountMode::NONE;
mode.set(AccountMode::SEND, account.send);
mode.set(AccountMode::RECV, account.receive);
bus::service(driver_bus_id(account.driver))
match bus::service(driver_bus_id(account.driver.clone()))
.call(Init::new(
account.address,
account.network,
account.token,
mode,
))
.await??;
log::debug!("Account initialized.");
Ok(())
.await
{
Ok(Ok(_)) => {
log::debug!("Account initialized.");
Ok(())
}
Ok(Err(e)) => {
let err_msg = format!(
"Failed to initialize account on driver: {} due to error {}",
account.driver, e
);
log::error!("{}", err_msg);
Err(anyhow!("{}", err_msg))
}
Err(e) => {
let err_msg = format!(
"Error during GSB call init account - Probably driver {} is not running and receiving messages: {}",
account.driver, e
);
log::error!("{}", err_msg);
Err(anyhow!("{}", err_msg))
}
}
}

0 comments on commit 800884b

Please sign in to comment.