Skip to content

Commit 07cbe73

Browse files
mz-pdmstsquad
authored andcommitted
scmi: Improve output on backend configuration error
Print a properly formatted error to both the log and terminal. Signed-off-by: Milan Zamazal <[email protected]>
1 parent 0261d31 commit 07cbe73

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

crates/scmi/src/main.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,12 @@ impl TryFrom<ScmiArgs> for VuScmiConfig {
107107
fn start_backend(config: VuScmiConfig) -> Result<()> {
108108
loop {
109109
debug!("Starting backend");
110-
// TODO: Print a nice error message on backend configuration failure.
111-
let backend = Arc::new(RwLock::new(VuScmiBackend::new(&config).unwrap()));
110+
let backend_instance = VuScmiBackend::new(&config);
111+
if let Err(error) = backend_instance {
112+
return Err(error.to_string());
113+
}
114+
115+
let backend = Arc::new(RwLock::new(backend_instance.unwrap()));
112116
let listener = Listener::new(config.socket_path.clone(), true).unwrap();
113117
let mut daemon = VhostUserDaemon::new(
114118
"vhost-device-scmi".to_owned(),
@@ -163,6 +167,7 @@ fn main() {
163167
Ok(config) => {
164168
if let Err(error) = start_backend(config) {
165169
error!("{error}");
170+
println!("{error}");
166171
exit(1);
167172
}
168173
}

0 commit comments

Comments
 (0)