mirror of
https://github.com/kata-containers/cgroups-rs.git
synced 2026-08-05 02:13:23 +00:00
Print cause when println!("{}")
> Print like following:
unable to write to a control group file caused by: Os { code: 22, kind: InvalidInput, message: "Invalid argument" }) }
Signed-off-by: Tim Zhang <tim@hyper.sh>
This commit is contained in:
@@ -66,7 +66,11 @@ impl fmt::Display for Error {
|
||||
ErrorKind::Other => "an unknown error".to_string(),
|
||||
};
|
||||
|
||||
write!(f, "{}", msg)
|
||||
if let Some(cause) = &self.cause {
|
||||
write!(f, "{} caused by: {:?}", msg, cause)
|
||||
} else {
|
||||
write!(f, "{}", msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user