Remove the .unwrap() from the mobile core (#2237)

So, `.unwrap()` can cause issues when the core dies by throwing a panic. So, by moving to a `match` instead, we can stop the panic from occurring.
This commit is contained in:
Arnab Chakraborty 2024-03-23 17:33:57 -04:00 committed by GitHub
parent e5b57aa0ea
commit 1baa5966d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -74,10 +74,15 @@ pub fn handle_core_msg(
None => {
let _guard = Node::init_logger(&data_dir);
// TODO: probably don't unwrap
let new_node = Node::new(data_dir, sd_core::Env::new(CLIENT_ID))
.await
.unwrap();
let new_node = match Node::new(data_dir, sd_core::Env::new(CLIENT_ID)).await {
Ok(node) => node,
Err(err) => {
error!("failed to initialise node: {}", err);
callback(Err(query));
return;
}
};
node.replace(new_node.clone());
new_node
}