mirror of
https://github.com/faas-rs/faasd-in-rust.git
synced 2025-06-08 15:56:48 +00:00
fix(bug): replace unwrap() with unwrap_or_default() to propagate errors for better handling
This commit is contained in:
parent
2f83a94476
commit
9277d3ef0b
@ -28,7 +28,7 @@ pub async fn get_function(function_name: &str, namespace: &str) -> Result<Functi
|
||||
let container = ContainerdManager::load_container(cid, namespace)
|
||||
.await
|
||||
.map_err(|e| FunctionError::FunctionNotFound(e.to_string()))?
|
||||
.unwrap();
|
||||
.unwrap_or_default();
|
||||
|
||||
let container_name = container.id.to_string();
|
||||
let image = container.image.clone();
|
||||
|
@ -492,8 +492,8 @@ impl ContainerdManager {
|
||||
|
||||
pub fn get_address(cid: &str) -> String {
|
||||
let map = GLOBAL_NETNS_MAP.read().unwrap();
|
||||
let config = map.get(cid).unwrap();
|
||||
config.get_address()
|
||||
let addr = map.get(cid).map(|net_conf| net_conf.get_address());
|
||||
addr.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn remove_container_network_config(cid: &str) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user