Skip to content

Commit

Permalink
Include txhash in errors
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Apr 25, 2024
1 parent 052a62f commit 825d593
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/cosmos/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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
);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/cosmos/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Action>,
grpc_url: Arc<String>,
Expand Down

0 comments on commit 825d593

Please sign in to comment.