diff --git a/common/client-core/src/client/base_client/mod.rs b/common/client-core/src/client/base_client/mod.rs index 02615f2b95..ad85157321 100644 --- a/common/client-core/src/client/base_client/mod.rs +++ b/common/client-core/src/client/base_client/mod.rs @@ -46,7 +46,6 @@ use nym_task::{TaskClient, TaskManager}; use nym_topology::provider_trait::TopologyProvider; use nym_validator_client::nyxd::contract_traits::DkgQueryClient; use std::sync::Arc; -use tap::TapFallible; use url::Url; #[cfg(all(not(target_arch = "wasm32"), feature = "fs-surb-storage"))] @@ -329,13 +328,18 @@ where ) }; + let gateway_id = gateway_client.gateway_identity(); gateway_client.set_disabled_credentials_mode(config.client.disabled_credentials_mode); let shared_key = gateway_client .authenticate_and_start() .await - .tap_err(|err| { - log::error!("Could not authenticate and start up the gateway connection - {err}") + .map_err(|err| { + log::error!("Could not authenticate and start up the gateway connection - {err}"); + ClientCoreError::GatewayClientError { + gateway_id: gateway_id.to_base58_string(), + source: err, + } })?; managed_keys.ensure_gateway_key(shared_key); diff --git a/common/client-core/src/error.rs b/common/client-core/src/error.rs index ff3f36e4cb..c0dc76f1e6 100644 --- a/common/client-core/src/error.rs +++ b/common/client-core/src/error.rs @@ -13,8 +13,11 @@ pub enum ClientCoreError { #[error("I/O error: {0}")] IoError(#[from] std::io::Error), - #[error("Gateway client error: {0}")] - GatewayClientError(#[from] GatewayClientError), + #[error("Gateway client error ({gateway_id}): {source}")] + GatewayClientError { + gateway_id: String, + source: GatewayClientError, + }, #[error("Ed25519 error: {0}")] Ed25519RecoveryError(#[from] Ed25519RecoveryError), diff --git a/common/client-core/src/init/helpers.rs b/common/client-core/src/init/helpers.rs index 6237321a1b..3f19d639ce 100644 --- a/common/client-core/src/init/helpers.rs +++ b/common/client-core/src/init/helpers.rs @@ -11,7 +11,6 @@ use nym_gateway_client::GatewayClient; use nym_topology::{filter::VersionFilterable, gateway}; use rand::{seq::SliceRandom, Rng}; use std::{sync::Arc, time::Duration}; -use tap::TapFallible; use tungstenite::Message; use url::Url; @@ -212,11 +211,23 @@ pub(super) async fn register_with_gateway( gateway_client .establish_connection() .await - .tap_err(|_| log::warn!("Failed to establish connection with gateway!"))?; + .map_err(|err| { + log::warn!("Failed to establish connection with gateway!"); + ClientCoreError::GatewayClientError { + gateway_id: gateway.gateway_id.clone(), + source: err, + } + })?; let shared_keys = gateway_client .perform_initial_authentication() .await - .tap_err(|_| log::warn!("Failed to register with the gateway!"))?; + .map_err(|err| { + log::warn!( "Failed to register with the gateway {}!", gateway.gateway_id); + ClientCoreError::GatewayClientError { + gateway_id: gateway.gateway_id.clone(), + source: err, + } + })?; Ok(RegistrationResult { shared_keys, authenticated_ephemeral_client: Some(gateway_client),