Mercurial > public > mercurial-scm > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
18964:ca480d710fe6 | 18965:0062508b1900 |
---|---|
684 def traceback(self, exc=None): | 684 def traceback(self, exc=None): |
685 '''print exception traceback if traceback printing enabled. | 685 '''print exception traceback if traceback printing enabled. |
686 only to call in exception handler. returns true if traceback | 686 only to call in exception handler. returns true if traceback |
687 printed.''' | 687 printed.''' |
688 if self.tracebackflag: | 688 if self.tracebackflag: |
689 if exc: | 689 if exc is None: |
690 exc = sys.exc_info() | |
691 cause = getattr(exc[1], 'cause', None) | |
692 | |
693 if cause is not None: | |
694 causetb = traceback.format_tb(cause[2]) | |
695 exctb = traceback.format_tb(exc[2]) | |
696 exconly = traceback.format_exception_only(cause[0], cause[1]) | |
697 | |
698 # exclude frame where 'exc' was chained and rethrown from exctb | |
699 self.write_err('Traceback (most recent call last):\n', | |
700 ''.join(exctb[:-1]), | |
701 ''.join(causetb), | |
702 ''.join(exconly)) | |
703 else: | |
690 traceback.print_exception(exc[0], exc[1], exc[2], | 704 traceback.print_exception(exc[0], exc[1], exc[2], |
691 file=self.ferr) | 705 file=self.ferr) |
692 else: | |
693 traceback.print_exc(file=self.ferr) | |
694 return self.tracebackflag | 706 return self.tracebackflag |
695 | 707 |
696 def geteditor(self): | 708 def geteditor(self): |
697 '''return editor to use''' | 709 '''return editor to use''' |
698 if sys.platform == 'plan9': | 710 if sys.platform == 'plan9': |