Mercurial > public > mercurial-scm > hg
diff mercurial/ui.py @ 18965:0062508b1900
ui: add support for fully printing chained exception stacks in ui.traceback()
Currently, only SubrepoAbort has a cause chained to it.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sat, 09 Feb 2013 14:15:34 -0500 |
parents | 18242716a014 |
children | 5572f688e0a9 |
line wrap: on
line diff
--- a/mercurial/ui.py Wed Feb 06 22:54:09 2013 -0500 +++ b/mercurial/ui.py Sat Feb 09 14:15:34 2013 -0500 @@ -686,11 +686,23 @@ only to call in exception handler. returns true if traceback printed.''' if self.tracebackflag: - if exc: + if exc is None: + exc = sys.exc_info() + cause = getattr(exc[1], 'cause', None) + + if cause is not None: + causetb = traceback.format_tb(cause[2]) + exctb = traceback.format_tb(exc[2]) + exconly = traceback.format_exception_only(cause[0], cause[1]) + + # exclude frame where 'exc' was chained and rethrown from exctb + self.write_err('Traceback (most recent call last):\n', + ''.join(exctb[:-1]), + ''.join(causetb), + ''.join(exconly)) + else: traceback.print_exception(exc[0], exc[1], exc[2], file=self.ferr) - else: - traceback.print_exc(file=self.ferr) return self.tracebackflag def geteditor(self):