fix: better bootstrap error message (#71)

This commit is contained in:
Noah Citron 2022-10-25 19:10:49 -04:00 committed by GitHub
parent 56d0ce5a72
commit e801b0b926
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View File

@ -15,17 +15,17 @@ impl BlockNotFoundError {
} }
#[derive(Debug, Error)] #[derive(Debug, Error)]
#[error("rpc error on method: {method}, message: {message}")] #[error("rpc error on method: {method}, message: {error}")]
pub struct RpcError { pub struct RpcError<E: ToString> {
method: String, method: String,
message: String, error: E,
} }
impl RpcError { impl<E: ToString> RpcError<E> {
pub fn new<E: ToString>(method: &str, err: E) -> Self { pub fn new(method: &str, err: E) -> Self {
Self { Self {
method: method.to_string(), method: method.to_string(),
message: err.to_string(), error: err,
} }
} }
} }

View File

@ -5,6 +5,7 @@ use std::time::UNIX_EPOCH;
use blst::min_pk::{PublicKey, Signature}; use blst::min_pk::{PublicKey, Signature};
use blst::BLST_ERROR; use blst::BLST_ERROR;
use chrono::Duration; use chrono::Duration;
use eyre::eyre;
use eyre::Result; use eyre::Result;
use log::{debug, info}; use log::{debug, info};
use ssz_rs::prelude::*; use ssz_rs::prelude::*;
@ -43,7 +44,10 @@ impl<R: Rpc> ConsensusClient<R> {
) -> Result<ConsensusClient<R>> { ) -> Result<ConsensusClient<R>> {
let rpc = R::new(rpc); 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( let committee_valid = is_current_committee_proof_valid(
&bootstrap.header, &bootstrap.header,