Skip to content

Commit f32a9b9

Browse files
author
Oleksandr Fedorenko
committed
fix error handling fot GET /block/:hash/txid/:index
1 parent 4919b68 commit f32a9b9

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/rest.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,14 @@ fn handle_request(
795795

796796
let txs = query
797797
.chain()
798-
.get_block_txs(&hash, start_index, CHAIN_TXS_PER_PAGE)?
798+
.get_block_txs(&hash, start_index, CHAIN_TXS_PER_PAGE)
799+
.map_err(|e| {
800+
if e.description().contains("block not found") {
801+
HttpError::not_found("Block not found".to_string())
802+
} else {
803+
HttpError::from(e)
804+
}
805+
})?
799806
.into_iter()
800807
.map(|tx| (tx, blockid))
801808
.collect();

0 commit comments

Comments
 (0)