Defined std::error::Error for HealthCheckerError
This commit is contained in:
@@ -2,6 +2,7 @@ use crate::result::HealthCheckResult;
|
||||
use directory_client::requests::presence_topology_get::PresenceTopologyGetRequester;
|
||||
use directory_client::DirectoryClient;
|
||||
use log::{debug, error, info, trace};
|
||||
use std::fmt::{Error, Formatter};
|
||||
use std::time::Duration;
|
||||
use topology::NymTopologyError;
|
||||
|
||||
@@ -16,6 +17,16 @@ pub enum HealthCheckerError {
|
||||
InvalidTopologyError,
|
||||
}
|
||||
|
||||
// required by std::error::Error
|
||||
impl std::fmt::Display for HealthCheckerError {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
|
||||
// just have implementation equivalent to derived debug
|
||||
write!(f, "{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for HealthCheckerError {}
|
||||
|
||||
impl From<topology::NymTopologyError> for HealthCheckerError {
|
||||
fn from(_: NymTopologyError) -> Self {
|
||||
use HealthCheckerError::*;
|
||||
@@ -45,7 +56,7 @@ impl HealthChecker {
|
||||
}
|
||||
}
|
||||
|
||||
async fn do_check(&self) -> Result<HealthCheckResult, HealthCheckerError> {
|
||||
pub async fn do_check(&self) -> Result<HealthCheckResult, HealthCheckerError> {
|
||||
trace!("going to perform a healthcheck!");
|
||||
let current_topology = match self.directory_client.presence_topology.get() {
|
||||
Ok(topology) => topology,
|
||||
@@ -61,7 +72,7 @@ impl HealthChecker {
|
||||
self.num_test_packets,
|
||||
self.resolution_timeout,
|
||||
)
|
||||
.await;
|
||||
.await;
|
||||
healthcheck_result.sort_scores();
|
||||
Ok(healthcheck_result)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user