Polish error handling

This commit is contained in:
hu55a1n1 2023-12-30 13:41:47 -08:00
parent 415ceefa00
commit 34d79e96d6

View file

@ -91,8 +91,10 @@ async fn main() -> Result<(), Box<dyn Error>> {
.abci_query(Some(path), data, Some(proof_height), true)
.await?;
let proof: RawCwProof = result.clone().try_into().expect("todo");
proof.verify(latest_app_hash.clone().into())?;
let proof: RawCwProof = result.clone().try_into().map_err(into_string)?;
proof
.verify(latest_app_hash.clone().into())
.map_err(into_string)?;
println!("{}", String::from_utf8(result.value.clone())?);
@ -105,6 +107,10 @@ async fn main() -> Result<(), Box<dyn Error>> {
Ok(())
}
fn into_string<E: ToString>(e: E) -> String {
e.to_string()
}
fn latest_proof_height_hash(status: Response) -> (Height, AppHash) {
let proof_height = {
let latest_height = status.sync_info.latest_block_height;