osbuild-mpp: fix YAMLError.problem accessors

The `problem` member is only defined if a problem-mark is present. If
the mark is not set, we get no details on the error whatsoever and have
to just print a generic error message.

Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
This commit is contained in:
David Rheinsberg 2022-09-13 12:52:41 +02:00 committed by Simon de Vlieger
parent 8c6049f197
commit 0471c646a8

View file

@ -927,11 +927,11 @@ class ManifestFile:
try:
data = yaml_load_ordered(f)
except yaml.YAMLError as err:
pos = ""
prob = ""
if hasattr(err, 'problem_mark'):
mark = err.problem_mark
pos = f" at line {mark.line+1} (col {mark.column+1})"
print(f"Invalid yaml in \"{path}\": {err.problem}{pos}")
prob = f": {err.problem} at line {mark.line+1} (col {mark.column+1})"
print(f"Invalid yaml in \"{path}\"{prob}")
sys.exit(1)
else:
try: