From 8a69aeb0b1013de028f979d4b38cbd5607621c45 Mon Sep 17 00:00:00 2001 From: Drew Tada Date: Tue, 20 Feb 2024 13:09:43 -0500 Subject: [PATCH] improved error messages --- kinode/packages/terminal/m/src/lib.rs | 12 ++++++++++-- kinode/src/kernel/mod.rs | 19 ++++++++++++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/kinode/packages/terminal/m/src/lib.rs b/kinode/packages/terminal/m/src/lib.rs index 34a468d6..112c030d 100644 --- a/kinode/packages/terminal/m/src/lib.rs +++ b/kinode/packages/terminal/m/src/lib.rs @@ -1,5 +1,7 @@ use clap::{Arg, Command}; -use kinode_process_lib::{await_next_request_body, call_init, println, Address, Request, Response}; +use kinode_process_lib::{ + await_next_request_body, call_init, println, Address, Request, Response, SendErrorKind, +}; use regex::Regex; wit_bindgen::generate!({ @@ -81,7 +83,13 @@ fn init(_our: Address) { let _ = Response::new().body(res.body()).send(); } Err(e) => { - println!("m: SendError: {:?}", e.kind); + println!( + "m: failed to send message {}", + match e.kind { + SendErrorKind::Timeout => "due to timeout", + SendErrorKind::Offline => "because the target is offline", + } + ); } } } diff --git a/kinode/src/kernel/mod.rs b/kinode/src/kernel/mod.rs index 574afd64..4b1638aa 100644 --- a/kinode/src/kernel/mod.rs +++ b/kinode/src/kernel/mod.rs @@ -917,8 +917,12 @@ pub async fn kernel( .send(t::Printout { verbosity: 0, content: format!( - "event loop: don't have {} amongst registered processes (got net error for it)", + "event loop: {} failed to deliver a message {}; sender has already terminated", wrapped_network_error.source.process, + match wrapped_network_error.error.kind { + t::SendErrorKind::Timeout => "due to timeout", + t::SendErrorKind::Offline => "because the receiver is offline", + }, ) }) .await; @@ -977,7 +981,11 @@ pub async fn kernel( .send(t::Printout { verbosity: 0, content: format!( - "event loop: don't have {} amongst registered processes (got message for it from network)", + "event loop: got {} from network for {}, but process does not exist (perhaps it terminated)", + match kernel_message.message { + t::Message::Request(_) => "Request", + t::Message::Response(_) => "Response", + }, kernel_message.target.process, ) }) @@ -1093,7 +1101,12 @@ pub async fn kernel( .send(t::Printout { verbosity: 0, content: format!( - "event loop: don't have {:?} amongst registered processes, got message for it: {}", + "event loop: got {} from {:?} for {:?}, but target doesn't exist (perhaps it terminated): {}", + match kernel_message.message { + t::Message::Request(_) => "Request", + t::Message::Response(_) => "Response", + }, + kernel_message.source.process, kernel_message.target.process, kernel_message, )