stree.serdes: Only ignore ENOENT for -include

-include ignores too many failures. It should only ignore ENOENT, all
others should throw an exception regardless.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-04-03 13:46:53 +02:00
commit 30c81af1b0

View file

@ -88,18 +88,16 @@ def _read_lines_from_one_path(path: str, throw=True, level=0, log_prio=INFO, pat
include_path = dir_name + '/' + include_path
include_lines = _read_lines(include_path, throw=(not optional), level=level+1, paths_buf=paths_buf)
if include_lines is None:
msg = f'{path}: Failed to process "{line}"'
slog(DEBUG, line)
slog(DEBUG, f'{path}: Failed to process "{line}"')
continue
ret.extend(include_lines)
continue
ret.append(line)
return ret
except Exception as e:
msg = f'Failed to read file "{path}": {e}'
if throw:
raise Exception(msg)
slog(DEBUG, msg)
slog(ERR, f'Failed to read file "{path}": {str(e)}')
if throw or not isinstance(e, FileNotFoundError):
raise
return None
def _read_lines(path: str, throw=True, level=0, log_prio=INFO, paths_buf=None):