summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <contact@benschubert.me>2019-07-30 09:51:41 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-07-30 10:57:25 +0000
commitfe0aa4c207893993d9f707b92f2169592b9cde20 (patch)
tree3cc8ef755ec9b6432740fd1a6606043177fb37ea
parentb5a5dd2426aeb44ba58fe763673e2f53c3b1e902 (diff)
downloadbuildstream-bschubert/debug-show-trace.tar.gz
app: Show stacktrace on exception when "--debug" is Truebschubert/debug-show-trace
Previously we would have the exceptions making debugging quite harder. When requesting '--debug', it seems ok to show the stack trace that created the error
-rw-r--r--src/buildstream/_frontend/app.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/buildstream/_frontend/app.py b/src/buildstream/_frontend/app.py
index 379ed4b7f..a5588e672 100644
--- a/src/buildstream/_frontend/app.py
+++ b/src/buildstream/_frontend/app.py
@@ -706,7 +706,17 @@ class App():
#
def _error_exit(self, error, prefix=None):
click.echo("", err=True)
- main_error = str(error)
+
+ if self.context is None or self.context.log_debug is None: # Context might not be initialized, default to cmd
+ debug = self._main_options["debug"]
+ else:
+ debug = self.context.log_debug
+
+ if debug:
+ main_error = "\n\n" + traceback.format_exc()
+ else:
+ main_error = str(error)
+
if prefix is not None:
main_error = "{}: {}".format(prefix, main_error)