Barely better error reporting

This commit is contained in:
Kodi Craft 2024-06-26 11:28:14 +02:00
parent d47f62cdbb
commit ef1faf5bd9
Signed by: kodi
GPG Key ID: 69D9EED60B242822

View File

@ -565,21 +565,21 @@ fn derive_protocol(input: proc_macro2::TokenStream) -> proc_macro2::TokenStream
}
pub fn insert(&self, nonce: u64, query: #query_enum_name) {
self.queries.lock().unwrap().insert(nonce, query);
self.queries.lock().expect("Could not insert new query; Mutex has been poisoned.").insert(nonce, query);
}
pub fn get(&self, nonce: &u64) -> ::std::option::Option<#query_enum_name> {
self.queries.lock().unwrap().get(nonce).cloned()
self.queries.lock().expect("Could not get query; Mutex has been poisoned.").get(nonce).cloned()
}
pub fn set_answer(&self, nonce: u64, answer: #answer_enum_name) {
if let ::std::option::Option::Some(query) = self.queries.lock().unwrap().get_mut(&nonce) {
if let ::std::option::Option::Some(query) = self.queries.lock().expect("Could not set answer to query; Mutex has been poisoned.").get_mut(&nonce) {
query.set_answer(answer);
}
}
pub fn len(&self) -> usize {
self.queries.lock().unwrap().len()
self.queries.lock().expect("Could not get query count; Mutex has been poisoned.").len()
}
}
};
@ -638,7 +638,9 @@ fn derive_protocol(input: proc_macro2::TokenStream) -> proc_macro2::TokenStream
} else {
match self.received.send(response).await {
::std::result::Result::Ok(_) => {},
::std::result::Result::Err(e) => #error("Failed to send received answer to : {:?}", e),
::std::result::Result::Err(e) => {
#error("Failed to send received answer to Client: {:?}", e);
},
};
}
buf.drain(0..(4 + len as usize));