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)
|
let container = ContainerdManager::load_container(cid, namespace)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| FunctionError::FunctionNotFound(e.to_string()))?
|
.map_err(|e| FunctionError::FunctionNotFound(e.to_string()))?
|
||||||
.unwrap();
|
.unwrap_or_default();
|
||||||
|
|
||||||
let container_name = container.id.to_string();
|
let container_name = container.id.to_string();
|
||||||
let image = container.image.clone();
|
let image = container.image.clone();
|
||||||
|
@ -492,8 +492,8 @@ impl ContainerdManager {
|
|||||||
|
|
||||||
pub fn get_address(cid: &str) -> String {
|
pub fn get_address(cid: &str) -> String {
|
||||||
let map = GLOBAL_NETNS_MAP.read().unwrap();
|
let map = GLOBAL_NETNS_MAP.read().unwrap();
|
||||||
let config = map.get(cid).unwrap();
|
let addr = map.get(cid).map(|net_conf| net_conf.get_address());
|
||||||
config.get_address()
|
addr.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_container_network_config(cid: &str) {
|
fn remove_container_network_config(cid: &str) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user