Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 2d50e53

Browse files
authored
don't wrap errors (#2830)
1 parent 2114d82 commit 2d50e53

File tree

3 files changed

+17
-9
lines changed
  • client

3 files changed

+17
-9
lines changed

client/network/src/tests.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,12 @@ impl RelayChainInterface for DummyRelayChainInterface {
242242
async fn header(&self, block_id: BlockId) -> RelayChainResult<Option<PHeader>> {
243243
let hash = match block_id {
244244
BlockId::Hash(hash) => hash,
245-
BlockId::Number(num) => self.relay_client.hash(num)?.ok_or_else(|| {
246-
RelayChainError::GenericError(format!("block with number {num} not found"))
247-
})?,
245+
BlockId::Number(num) =>
246+
if let Some(hash) = self.relay_client.hash(num)? {
247+
hash
248+
} else {
249+
return Ok(None)
250+
},
248251
};
249252
let header = self.relay_client.header(hash)?;
250253

client/relay-chain-inprocess-interface/src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,12 @@ impl RelayChainInterface for RelayChainInProcessInterface {
9494
async fn header(&self, block_id: BlockId) -> RelayChainResult<Option<PHeader>> {
9595
let hash = match block_id {
9696
BlockId::Hash(hash) => hash,
97-
BlockId::Number(num) => self.full_client.hash(num)?.ok_or_else(|| {
98-
RelayChainError::GenericError(format!("block with number {num} not found"))
99-
})?,
97+
BlockId::Number(num) =>
98+
if let Some(hash) = self.full_client.hash(num)? {
99+
hash
100+
} else {
101+
return Ok(None)
102+
},
100103
};
101104
let header = self.full_client.header(hash)?;
102105

client/relay-chain-rpc-interface/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ impl RelayChainInterface for RelayChainRpcInterface {
8282
let hash = match block_id {
8383
BlockId::Hash(hash) => hash,
8484
BlockId::Number(num) =>
85-
self.rpc_client.chain_get_block_hash(Some(num)).await?.ok_or_else(|| {
86-
RelayChainError::GenericError(format!("block with number {num} not found"))
87-
})?,
85+
if let Some(hash) = self.rpc_client.chain_get_block_hash(Some(num)).await? {
86+
hash
87+
} else {
88+
return Ok(None)
89+
},
8890
};
8991
let header = self.rpc_client.chain_get_header(Some(hash)).await?;
9092

0 commit comments

Comments
 (0)