From 825d5938f0993807d4d127d3f842c07cbe019249 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Thu, 25 Apr 2024 08:29:06 +0300 Subject: [PATCH] Include txhash in errors --- packages/cosmos/src/client.rs | 5 ++++- packages/cosmos/src/error.rs | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/cosmos/src/client.rs b/packages/cosmos/src/client.rs index cf063e9..e42b581 100644 --- a/packages/cosmos/src/client.rs +++ b/packages/cosmos/src/client.rs @@ -1516,6 +1516,7 @@ impl TxBuilder { if !self.skip_code_check && res.code != 0 { return Err(crate::Error::TransactionFailed { code: res.code.into(), + txhash: res.txhash.clone(), raw_log: res.raw_log, action: Action::Broadcast(self.clone()).into(), grpc_url, @@ -1531,6 +1532,7 @@ impl TxBuilder { if !self.skip_code_check && res.code != 0 { return Err(crate::Error::TransactionFailed { code: res.code.into(), + txhash: res.txhash.clone(), raw_log: res.raw_log, action: Action::Broadcast(self.clone()).into(), grpc_url, @@ -1555,13 +1557,14 @@ impl TxBuilder { match retry_with_price(amount).await { Err(crate::Error::TransactionFailed { code: CosmosSdkError::InsufficientFee, + txhash, raw_log, action: _, grpc_url: _, stage: _, }) => { tracing::debug!( - "Insufficient gas in attempt #{}, retrying. Raw log: {raw_log}", + "Insufficient gas in attempt #{}, retrying {txhash}. Raw log: {raw_log}", attempt_number + 1 ); } diff --git a/packages/cosmos/src/error.rs b/packages/cosmos/src/error.rs index c54e9b9..8d0c4ac 100644 --- a/packages/cosmos/src/error.rs +++ b/packages/cosmos/src/error.rs @@ -202,9 +202,10 @@ pub enum Error { path: PathBuf, source: std::io::Error, }, - #[error("Transaction failed ({grpc_url}) during {stage} with {code} and log: {raw_log}. Action: {action}.")] + #[error("Transaction {txhash} failed (on {grpc_url}) during {stage} with {code} and log: {raw_log}. Action: {action}.")] TransactionFailed { code: CosmosSdkError, + txhash: String, raw_log: String, action: Arc, grpc_url: Arc,