Skip to content

Commit 8ac2240

Browse files
committed
[nrf noup] [west zap-gui] Refine error handling
It turns out that the subprocess may return no output if the Chromium cannot use sandbox due to the missing permissions. Added a workaround that raises an exception if the command execution output is empty, so that it can be handled with the fix_sandbox_permissions() call. Signed-off-by: Marcin Kajor <marcin.kajor@nordicsemi.no>
1 parent 19518c5 commit 8ac2240

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

‎scripts/west/zap_common.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,13 +299,13 @@ def __exit__(self, exc_type, exc_val, exc_tb):
299299

300300
def display_zap_message(output: subprocess.CompletedProcess[str]) -> None:
301301
"""
302-
If the output contains the error from napi_throw, suggest user to use zap-sync to sync the ZAP file.
302+
If the output contains the error from napi_throw, suggest user to use zap-sync to sync the ZAP file and make sure that all attributes are provided.
303303
"""
304+
print(f"output: {output.stdout}")
304305
if 'Unknown attribute' in output.stdout:
305-
log.err("Your zcl.json file seems to be outdated. Please use 'west zap-sync' command to synchronize it with the newest Matter Data Model.")
306-
return
307-
else:
308-
print(f"output: {output.stdout}")
306+
log.err("Your zcl.json file seems to be outdated or is missing some attributes. "
307+
"Please use 'west zap-sync' command to synchronize it with the newest Matter Data Model "
308+
"and make sure that all cluster attributes are properly defined in the cluster XML file.")
309309

310310

311311
class ZapInstaller:

‎scripts/west/zap_gui.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ def run_zap():
102102
cmd += ["--tempState"]
103103

104104
output = subprocess.run([str(x) for x in cmd], capture_output=True, text=True)
105+
# Chromium often prints nothing to stdout when the sandbox aborts early.
106+
# returncode -5 is a sentinel consumed by fix_sandbox_permissions().
107+
if not output.stdout:
108+
raise subprocess.CalledProcessError(-5, cmd)
105109
display_zap_message(output)
106110
return output
107111

0 commit comments

Comments
 (0)