mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-23 08:32:23 +03:00
Merge pull request #261 from kinode-dao/da/kernel-errors
Da/kernel errors
This commit is contained in:
commit
971a5f30e1
@ -148,7 +148,7 @@ fn main(our: Address, mut state: State) -> anyhow::Result<()> {
|
||||
);
|
||||
// if contract address changed from a previous run, reset state
|
||||
if state.contract_address != contract_address {
|
||||
println!("resetting state for some reason.");
|
||||
println!("kns_indexer: contract address changed, re-indexing");
|
||||
state = State {
|
||||
contract_address: contract_address.clone(),
|
||||
names: HashMap::new(),
|
||||
|
@ -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!({
|
||||
@ -78,10 +80,24 @@ fn init(_our: Address) {
|
||||
println!("m: awaiting response for {}s", s);
|
||||
match req.send_and_await_response(*s).unwrap() {
|
||||
Ok(res) => {
|
||||
let _ = Response::new().body(res.body()).send();
|
||||
// TODO piping is broken. Patching it by just printing the response
|
||||
// let _ = Response::new().body(res.body()).send();
|
||||
if let Ok(txt) = std::str::from_utf8(&res.body()) {
|
||||
println!("{txt}");
|
||||
} else {
|
||||
println!("{:?}", res.body());
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
println!("m: SendError: {:?}", e.kind);
|
||||
println!(
|
||||
"m: {}",
|
||||
match e.kind {
|
||||
SendErrorKind::Timeout =>
|
||||
"target did not send Response in time, try increasing the await time",
|
||||
SendErrorKind::Offline =>
|
||||
"failed to send message because the target is offline",
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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,8 +981,17 @@ 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{}",
|
||||
match kernel_message.message {
|
||||
t::Message::Request(_) => "Request",
|
||||
t::Message::Response(_) => "Response",
|
||||
},
|
||||
kernel_message.target.process,
|
||||
match kernel_message.message {
|
||||
t::Message::Request(_) => "",
|
||||
t::Message::Response(_) =>
|
||||
"\nhint: if you are using `m`, try awaiting the Response: `m --await 5 ...`",
|
||||
}
|
||||
)
|
||||
})
|
||||
.await;
|
||||
@ -1093,7 +1106,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,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user