From 14e025a5a1c946f84a919d9fc5bba6891a6e5197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Mon, 10 Jul 2023 11:59:26 +0200 Subject: [PATCH] pkgset: Emit better error for missing modulemd file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ář --- pungi/phases/pkgset/sources/source_koji.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pungi/phases/pkgset/sources/source_koji.py b/pungi/phases/pkgset/sources/source_koji.py index 04301587..712af11e 100644 --- a/pungi/phases/pkgset/sources/source_koji.py +++ b/pungi/phases/pkgset/sources/source_koji.py @@ -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