pkgset: Emit better error for missing modulemd file

The exceptions from libmodulemd are not particularly helpful as they do
not contain information about what file caused it.

   modulemd-yaml-error-quark: Failed to open file: Permission denied (0)

This patch should add the path to the problematic file into the message.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
(cherry picked from commit 14e025a5a1)
This commit is contained in:
Lubomír Sedlář 2023-07-10 11:59:26 +02:00 committed by Stepan Oksanichenko
parent f3485410ad
commit f17628dd5f
Signed by: soksanichenko
GPG Key ID: AB9983172AB1E45B

View File

@ -270,9 +270,14 @@ def _add_module_to_variant(
"Module %s does not have metadata for arch %s and is not filtered "
"out via filter_modules option." % (nsvc, arch)
)
mod_stream = read_single_module_stream_from_file(
mmds[filename], compose, arch, build
)
try:
mod_stream = read_single_module_stream_from_file(
mmds[filename], compose, arch, build
)
except Exception as exc:
# libmodulemd raises various GLib exceptions with not very helpful
# messages. Let's replace it with something more useful.
raise RuntimeError("Failed to read %s: %s", mmds[filename], str(exc))
if mod_stream:
added = True
variant.arch_mmds.setdefault(arch, {})[nsvc] = mod_stream