improved error messages

This commit is contained in:
Drew Tada 2024-02-20 13:09:43 -05:00
parent 52c168e7b9
commit 8a69aeb0b1
2 changed files with 26 additions and 5 deletions

View File

@ -1,5 +1,7 @@
use clap::{Arg, Command}; 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; use regex::Regex;
wit_bindgen::generate!({ wit_bindgen::generate!({
@ -81,7 +83,13 @@ fn init(_our: Address) {
let _ = Response::new().body(res.body()).send(); let _ = Response::new().body(res.body()).send();
} }
Err(e) => { 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",
}
);
} }
} }
} }

View File

@ -917,8 +917,12 @@ pub async fn kernel(
.send(t::Printout { .send(t::Printout {
verbosity: 0, verbosity: 0,
content: format!( 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, 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; .await;
@ -977,7 +981,11 @@ pub async fn kernel(
.send(t::Printout { .send(t::Printout {
verbosity: 0, verbosity: 0,
content: format!( 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, kernel_message.target.process,
) )
}) })
@ -1093,7 +1101,12 @@ pub async fn kernel(
.send(t::Printout { .send(t::Printout {
verbosity: 0, verbosity: 0,
content: format!( 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.target.process,
kernel_message, kernel_message,
) )