Skip to content

Commit 4158fc7

Browse files
committed
Per review feedback: use std::any::type_name::<T>() so errors identify which type (Block, Transaction, BlockHeader) failed.
1 parent 4f7bf8b commit 4158fc7

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/daemon.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,15 @@ fn tx_from_value(value: Value) -> Result<Transaction> {
7979

8080
#[cfg(not(feature = "liquid"))]
8181
fn deserialize_value<T: bitcoin::consensus::Decodable>(hex: &str) -> Result<T> {
82-
Ok(deserialize_hex(hex).chain_err(|| "failed to deserialize hex")?)
82+
Ok(deserialize_hex(hex)
83+
.chain_err(|| format!("failed to deserialize {}", std::any::type_name::<T>()))?)
8384
}
8485

8586
#[cfg(feature = "liquid")]
8687
fn deserialize_value<T: elements::encode::Decodable>(hex: &str) -> Result<T> {
8788
let bytes = Vec::from_hex(hex).chain_err(|| "invalid hex")?;
88-
Ok(deserialize(&bytes).chain_err(|| "failed to deserialize")?)
89+
Ok(deserialize(&bytes)
90+
.chain_err(|| format!("failed to deserialize {}", std::any::type_name::<T>()))?)
8991
}
9092

9193
/// Parse JSONRPC error code, if exists.

0 commit comments

Comments
 (0)