From 7c956a75c074b7c24bd98267816ac6ca41452f10 Mon Sep 17 00:00:00 2001 From: Kristian Glass Date: Wed, 30 Oct 2024 14:23:50 +0000 Subject: [PATCH] Expose ImportError when trying to import config modules raise-ing a utils.ErrorMessage hides the details of the underlying exception without --debug As a user, I'd like a little more information about what has gone wrong when my tool has a critical failure like this - I don't want to have to re-run it (which could be nontrivial) I appreciate using debug logging for otherwise-overly-verbose information that might help me understand internal behaviour better, but for fundamental failures like "your config file is so broken that the tool won't run", I want useful information alongside the failure. --- ghconf/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ghconf/main.py b/ghconf/main.py index 0cada07..334df65 100644 --- a/ghconf/main.py +++ b/ghconf/main.py @@ -173,7 +173,8 @@ def main() -> None: else: raise utils.ErrorMessage("Module %s has no `entry_point` top-level variable" % module) except ImportError as e: - raise utils.ErrorMessage("Can't import module %s (use --debug for more information)" % module) from e + print_error("Can't import module %s" % module) + raise e parser = ArgumentParser(description="ghconf is a tool that parses declarative configuration files in a Python DSL " "and then runs Python modules against a preconfigured PyGithub instance. This "