Skip to content

Commit

Permalink
Improved error messages for client state/consensus queries (#1795)
Browse files Browse the repository at this point in the history
* Improved error messages for client state/consensus queries

* FMT
  • Loading branch information
adizere authored Jan 21, 2022
1 parent 773e50c commit 4310f92
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion modules/src/core/ics02_client/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ define_error! {
},

EmptyConsensusStateResponse
| _ | { "the client state was not found" },
| _ | { "the client consensus state was not found" },

UnknownHeaderType
{ header_type: String }
Expand Down
21 changes: 19 additions & 2 deletions relayer/src/foreign_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,22 @@ define_error! {
}
[ RelayerError ]
|e| {
format_args!("failed while querying Tx for client {0} on chain id: {1}",
format_args!("failed while querying for client {0} on chain id {1}",
e.client_id, e.chain_id)
},

ClientConsensusQuery
{
client_id: ClientId,
chain_id: ChainId,
height: Height
}
[ RelayerError ]
|e| {
format_args!("failed while querying for client consensus state {0} on chain id {1} for height {2}",
e.client_id, e.chain_id, e.height)
},

ClientUpgrade
{
client_id: ClientId,
Expand Down Expand Up @@ -1043,7 +1055,12 @@ impl<DstChain: ChainHandle, SrcChain: ChainHandle> ForeignClient<DstChain, SrcCh
.dst_chain
.query_consensus_state(self.id.clone(), height, Height::zero())
.map_err(|e| {
ForeignClientError::client_query(self.id.clone(), self.dst_chain.id(), e)
ForeignClientError::client_consensus_query(
self.id.clone(),
self.dst_chain.id(),
height,
e,
)
})?;

Ok(res)
Expand Down

0 comments on commit 4310f92

Please sign in to comment.