From e52434aa18058d458162cf1f7f8f8dbfb22f38eb Mon Sep 17 00:00:00 2001 From: Ted Bauer Date: Fri, 8 Mar 2024 20:56:42 +0000 Subject: [PATCH] aflags: make flag storage error message more user-friendly Bug: 328577149 Test: adb shell stop && sleep 10 && adb shell aflags list Change-Id: Idb28c93f883b72031cf3e1ff4e8d396c4df708e2 --- tools/aconfig/aflags/src/device_config_source.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/aconfig/aflags/src/device_config_source.rs b/tools/aconfig/aflags/src/device_config_source.rs index 2589f3d8a6..f1a1f0dc2d 100644 --- a/tools/aconfig/aflags/src/device_config_source.rs +++ b/tools/aconfig/aflags/src/device_config_source.rs @@ -104,11 +104,16 @@ fn read_device_config_output(command: &[&str]) -> Result { if !output.status.success() { let reason = match output.status.code() { Some(code) => { - format!("exit code {}, output was {}", code, str::from_utf8(&output.stdout)?) + let output = str::from_utf8(&output.stdout)?; + if !output.is_empty() { + format!("exit code {code}, output was {output}") + } else { + format!("exit code {code}") + } } None => "terminated by signal".to_string(), }; - bail!("failed to execute device_config: {}", reason); + bail!("failed to access flag storage: {}", reason); } Ok(str::from_utf8(&output.stdout)?.to_string()) }