diff options
author | Harmen Stoppels <harmenstoppels@gmail.com> | 2022-10-31 13:49:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-31 12:49:19 +0000 |
commit | a4930c74cbcb403c118495f56f8d3778976f2955 (patch) | |
tree | 90e997d3b1d2247042943f48d9937dffce0cd7c4 /lib | |
parent | 1ab888cdc1b0a42c9d855aacc0bacab6d7efb788 (diff) | |
download | spack-a4930c74cbcb403c118495f56f8d3778976f2955.tar.gz spack-a4930c74cbcb403c118495f56f8d3778976f2955.tar.bz2 spack-a4930c74cbcb403c118495f56f8d3778976f2955.tar.xz spack-a4930c74cbcb403c118495f56f8d3778976f2955.zip |
Make --backtrace show non-SpackError backtraces (#33540)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/main.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/spack/spack/main.py b/lib/spack/spack/main.py index 998d0e2022..4c3f19d75d 100644 --- a/lib/spack/spack/main.py +++ b/lib/spack/spack/main.py @@ -107,6 +107,9 @@ required_command_properties = ["level", "section", "description"] spack_working_dir = None spack_ld_library_path = os.environ.get("LD_LIBRARY_PATH", "") +#: Whether to print backtraces on error +SHOW_BACKTRACE = False + def set_working_dir(): """Change the working directory to getcwd, or spack prefix if no cwd.""" @@ -569,6 +572,8 @@ def setup_main_options(args): if args.debug or args.backtrace: spack.error.debug = True + global SHOW_BACKTRACE + SHOW_BACKTRACE = True if args.debug: spack.util.debug.register_interrupt_handler() @@ -1002,7 +1007,7 @@ def main(argv=None): e.die() # gracefully die on any SpackErrors except KeyboardInterrupt: - if spack.config.get("config:debug"): + if spack.config.get("config:debug") or SHOW_BACKTRACE: raise sys.stderr.write("\n") tty.error("Keyboard interrupt.") @@ -1012,12 +1017,12 @@ def main(argv=None): return signal.SIGINT except SystemExit as e: - if spack.config.get("config:debug"): + if spack.config.get("config:debug") or SHOW_BACKTRACE: traceback.print_exc() return e.code except Exception as e: - if spack.config.get("config:debug"): + if spack.config.get("config:debug") or SHOW_BACKTRACE: raise tty.error(e) return 3 |