agent: remove unwrap() for e.as_errno()

Use `{:?}` to print `e.as_errno()` instead of using `{}`
to print `e.as_errno().unwrap().desc()`.

Avoid panic only caused by error's content.

Signed-off-by: Tim Zhang <tim@hyper.sh>
This commit is contained in:
Tim Zhang 2020-10-14 10:18:00 +08:00
parent e77482fe16
commit 6ba294a11e
2 changed files with 6 additions and 11 deletions

View File

@ -397,7 +397,7 @@ fn do_init_child(cwfd: RawFd) -> Result<()> {
ns.r#type.clone(), ns.r#type.clone(),
ns.path.clone() ns.path.clone()
); );
log_child!(cfd_log, "error is : {}", e.as_errno().unwrap().desc()); log_child!(cfd_log, "error is : {:?}", e.as_errno());
e e
})?; })?;
@ -1080,7 +1080,7 @@ fn get_pid_namespace(logger: &Logger, linux: &Linux) -> Result<Option<RawFd>> {
ns.r#type.clone(), ns.r#type.clone(),
ns.path.clone() ns.path.clone()
); );
error!(logger, "error is : {}", e.as_errno().unwrap().desc()); error!(logger, "error is : {:?}", e.as_errno());
e e
})?; })?;

View File

@ -712,9 +712,9 @@ fn mount_from(
let _ = stat::stat(dest.as_str()).map_err(|e| { let _ = stat::stat(dest.as_str()).map_err(|e| {
log_child!( log_child!(
cfd_log, cfd_log,
"dest stat error. {}: {}", "dest stat error. {}: {:?}",
dest.as_str(), dest.as_str(),
e.as_errno().unwrap().desc() e.as_errno()
) )
}); });
@ -726,7 +726,7 @@ fn mount_from(
Some(d.as_str()), Some(d.as_str()),
) )
.map_err(|e| { .map_err(|e| {
log_child!(cfd_log, "mount error: {}", e.as_errno().unwrap().desc()); log_child!(cfd_log, "mount error: {:?}", e.as_errno());
e e
})?; })?;
@ -748,12 +748,7 @@ fn mount_from(
None::<&str>, None::<&str>,
) )
.map_err(|e| { .map_err(|e| {
log_child!( log_child!(cfd_log, "remout {}: {:?}", dest.as_str(), e.as_errno());
cfd_log,
"remout {}: {}",
dest.as_str(),
e.as_errno().unwrap().desc()
);
e e
})?; })?;
} }