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:
parent
8c6049f197
commit
0471c646a8
1 changed files with 3 additions and 3 deletions
|
|
@ -927,11 +927,11 @@ class ManifestFile:
|
||||||
try:
|
try:
|
||||||
data = yaml_load_ordered(f)
|
data = yaml_load_ordered(f)
|
||||||
except yaml.YAMLError as err:
|
except yaml.YAMLError as err:
|
||||||
pos = ""
|
prob = ""
|
||||||
if hasattr(err, 'problem_mark'):
|
if hasattr(err, 'problem_mark'):
|
||||||
mark = err.problem_mark
|
mark = err.problem_mark
|
||||||
pos = f" at line {mark.line+1} (col {mark.column+1})"
|
prob = f": {err.problem} at line {mark.line+1} (col {mark.column+1})"
|
||||||
print(f"Invalid yaml in \"{path}\": {err.problem}{pos}")
|
print(f"Invalid yaml in \"{path}\"{prob}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue