summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Magnusson <foo@bar.com>2018-11-01 02:48:30 +0100
committerUlf Magnusson <foo@bar.com>2018-11-01 03:21:09 +0100
commit8be38f27788239739619db86b6e5270ef7905511 (patch)
tree37679022d8ba6fa28cecdc1968bb09a0fb8e870c
parentd30b55043c4c771cdabf42847cf718a93cf86ab8 (diff)
Don't show backtraces for expected exceptions in tools
KconfigError and IOError are part of normal operation and don't indicate a problem with the library itself. Catch and print them in standard_kconfig() and sys.exit(), to avoid spammy backtraces from e.g. menuconfig.py when Kconfig files don't exist or have errors.
-rw-r--r--kconfiglib.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index 1e320a5..eae271e 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -5585,7 +5585,13 @@ def standard_kconfig():
if len(sys.argv) > 2:
sys.exit("usage: {} [Kconfig]".format(sys.argv[0]))
- return Kconfig("Kconfig" if len(sys.argv) < 2 else sys.argv[1])
+ # Only show backtraces for unexpected exceptions
+ try:
+ return Kconfig("Kconfig" if len(sys.argv) < 2 else sys.argv[1])
+ except (IOError, KconfigError) as e:
+ # Some long exception messages have extra newlines for better
+ # formatting when reported as an unhandled exception. Strip them here.
+ sys.exit(str(e).strip())
def standard_config_filename():
"""