From e801b0b926bdbec4f96e21c5246a5f5264ede92e Mon Sep 17 00:00:00 2001 From: Noah Citron Date: Tue, 25 Oct 2022 19:10:49 -0400 Subject: [PATCH] fix: better bootstrap error message (#71) --- common/src/errors.rs | 12 ++++++------ consensus/src/consensus.rs | 6 +++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/common/src/errors.rs b/common/src/errors.rs index b5b8e52..b455fd4 100644 --- a/common/src/errors.rs +++ b/common/src/errors.rs @@ -15,17 +15,17 @@ impl BlockNotFoundError { } #[derive(Debug, Error)] -#[error("rpc error on method: {method}, message: {message}")] -pub struct RpcError { +#[error("rpc error on method: {method}, message: {error}")] +pub struct RpcError { method: String, - message: String, + error: E, } -impl RpcError { - pub fn new(method: &str, err: E) -> Self { +impl RpcError { + pub fn new(method: &str, err: E) -> Self { Self { method: method.to_string(), - message: err.to_string(), + error: err, } } } diff --git a/consensus/src/consensus.rs b/consensus/src/consensus.rs index 9a55b7b..2f5eb57 100644 --- a/consensus/src/consensus.rs +++ b/consensus/src/consensus.rs @@ -5,6 +5,7 @@ use std::time::UNIX_EPOCH; use blst::min_pk::{PublicKey, Signature}; use blst::BLST_ERROR; use chrono::Duration; +use eyre::eyre; use eyre::Result; use log::{debug, info}; use ssz_rs::prelude::*; @@ -43,7 +44,10 @@ impl ConsensusClient { ) -> Result> { let rpc = R::new(rpc); - let mut bootstrap = rpc.get_bootstrap(checkpoint_block_root).await?; + let mut bootstrap = rpc + .get_bootstrap(checkpoint_block_root) + .await + .map_err(|_| eyre!("could not fetch bootstrap"))?; let committee_valid = is_current_committee_proof_valid( &bootstrap.header,