@@ -28,6 +28,7 @@ use std::{
2828 sync:: { Arc , RwLock } ,
2929} ;
3030
31+ use eyre:: Context ;
3132use nts_pool_shared:: { ProbeControlCommand , ProbeResult } ;
3233use serde:: Serialize ;
3334use tokio:: {
@@ -55,7 +56,7 @@ trait ProbeExecutor {
5556 fn run_probe (
5657 self : Arc < Self > ,
5758 timesource : ( IpVersion , String ) ,
58- ) -> impl Future < Output = Result < Self :: Output , std :: io :: Error > > + Send ;
59+ ) -> impl Future < Output = Result < Self :: Output , eyre :: Error > > + Send ;
5960}
6061
6162impl ProbeExecutor for Probe {
@@ -78,7 +79,7 @@ impl ProbeExecutor for Probe {
7879 async fn run_probe (
7980 self : Arc < Self > ,
8081 timesource : ( IpVersion , String ) ,
81- ) -> Result < Self :: Output , std :: io :: Error > {
82+ ) -> Result < Self :: Output , eyre :: Error > {
8283 self . probe ( timesource. 1 , timesource. 0 ) . await
8384 }
8485}
@@ -87,7 +88,7 @@ impl ProbeExecutor for Probe {
8788trait ManagementRequestor {
8889 fn get_command (
8990 config : & ProbeControlConfig ,
90- ) -> impl Future < Output = Result < ProbeControlCommand , std :: io :: Error > > + Send ;
91+ ) -> impl Future < Output = Result < ProbeControlCommand , eyre :: Error > > + Send ;
9192}
9293
9394async fn run_probing_inner <
@@ -104,7 +105,7 @@ async fn run_probing_inner<
104105 let command = match M :: get_command ( & config) . await {
105106 Ok ( command) => command,
106107 Err ( e) => {
107- error ! ( "Could not fetch initial command: {}" , e) ;
108+ error ! ( "Could not fetch initial command: {:? }" , e) ;
108109 std:: process:: exit ( crate :: exitcode:: SOFTWARE ) ;
109110 }
110111 } ;
@@ -311,16 +312,17 @@ async fn run_result_reporter<T: Send + Serialize + 'static>(
311312struct ReqwestManagementRequestor ;
312313
313314impl ManagementRequestor for ReqwestManagementRequestor {
314- async fn get_command (
315- config : & ProbeControlConfig ,
316- ) -> Result < ProbeControlCommand , std:: io:: Error > {
315+ async fn get_command ( config : & ProbeControlConfig ) -> Result < ProbeControlCommand , eyre:: Error > {
317316 let result = reqwest:: Client :: new ( )
318317 . get ( & config. management_interface )
319318 . bearer_auth ( & config. authorization_key )
320319 . send ( )
321320 . await
322- . map_err ( std:: io:: Error :: other) ?;
323- result. json ( ) . await . map_err ( std:: io:: Error :: other)
321+ . wrap_err ( "Failed to send probe request/get probe response" ) ?;
322+ result
323+ . json ( )
324+ . await
325+ . wrap_err ( "Could not convert JSON response to probe command" )
324326 }
325327}
326328
@@ -371,7 +373,7 @@ mod tests {
371373 async fn run_probe (
372374 self : Arc < Self > ,
373375 timesource : ( IpVersion , String ) ,
374- ) -> Result < Self :: Output , std :: io :: Error > {
376+ ) -> Result < Self :: Output , eyre :: Error > {
375377 Ok ( timesource)
376378 }
377379 }
@@ -497,7 +499,7 @@ mod tests {
497499 impl ManagementRequestor for BasicCommandRequestor {
498500 async fn get_command (
499501 _config : & ProbeControlConfig ,
500- ) -> Result < ProbeControlCommand , std :: io :: Error > {
502+ ) -> Result < ProbeControlCommand , eyre :: Error > {
501503 Ok ( ProbeControlCommand {
502504 timesources : [
503505 ( IpVersion :: Ipv4 , "A" . to_string ( ) ) ,
@@ -571,7 +573,7 @@ mod tests {
571573 impl ManagementRequestor for SequencedCommandRequestor {
572574 async fn get_command (
573575 _config : & ProbeControlConfig ,
574- ) -> Result < ProbeControlCommand , std :: io :: Error > {
576+ ) -> Result < ProbeControlCommand , eyre :: Error > {
575577 static INDEX : AtomicUsize = AtomicUsize :: new ( 0 ) ;
576578 Ok ( match INDEX . load ( std:: sync:: atomic:: Ordering :: SeqCst ) {
577579 0 => {
0 commit comments