Barely better error reporting
This commit is contained in:
parent
d47f62cdbb
commit
ef1faf5bd9
12
src/lib.rs
12
src/lib.rs
@ -565,21 +565,21 @@ fn derive_protocol(input: proc_macro2::TokenStream) -> proc_macro2::TokenStream
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn insert(&self, nonce: u64, query: #query_enum_name) {
|
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> {
|
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) {
|
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);
|
query.set_answer(answer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn len(&self) -> usize {
|
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 {
|
} else {
|
||||||
match self.received.send(response).await {
|
match self.received.send(response).await {
|
||||||
::std::result::Result::Ok(_) => {},
|
::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));
|
buf.drain(0..(4 + len as usize));
|
||||||
|
Loading…
Reference in New Issue
Block a user