Popen_safe_logged: Also log exceptions

Popen can raise OSError when program is not found, or PermissionError if
not executable, etc.
This commit is contained in:
Xavier Claessens 2023-08-09 14:33:08 -04:00 committed by Xavier Claessens
parent 711e4e3b06
commit 13b626b67b
1 changed files with 7 additions and 1 deletions

View File

@ -1547,7 +1547,13 @@ def Popen_safe_logged(args: T.List[str], msg: str = 'Called', **kwargs: T.Any) -
'''
Wrapper around Popen_safe that assumes standard piped o/e and logs this to the meson log.
'''
p, o, e = Popen_safe(args, **kwargs)
try:
p, o, e = Popen_safe(args, **kwargs)
except Exception as excp:
mlog.debug('-----------')
mlog.debug(f'{msg}: `{join_args(args)}` -> {excp}')
raise
rc, out, err = p.returncode, o.strip(), e.strip()
mlog.debug('-----------')
mlog.debug(f'{msg}: `{join_args(args)}` -> {rc}')