Format call-stack and display exception information (if availible)
(frame=None)
| 755 | |
| 756 | |
| 757 | def format_exc(frame=None): |
| 758 | """ |
| 759 | Format call-stack and display exception information (if availible) |
| 760 | """ |
| 761 | exc_info = sys.exc_info() |
| 762 | exc_desc = u"" |
| 763 | |
| 764 | callstack = traceback.extract_stack(frame) |
| 765 | callstack = callstack[:-1] |
| 766 | |
| 767 | if exc_info[0] is not None: |
| 768 | exception_callstack = traceback.extract_tb(exc_info[2]) |
| 769 | |
| 770 | # @NOTE: Does this exception belongs to us? |
| 771 | if callstack[-1][0] == exception_callstack[0][0]: |
| 772 | callstack = callstack[:-1] |
| 773 | callstack.extend(exception_callstack) |
| 774 | exc_desc = decode("".join(traceback.format_exception_only(exc_info[0], exc_info[1]))) |
| 775 | |
| 776 | msg = u"Traceback (most recent call last):\n" |
| 777 | msg += decode("".join(traceback.format_list(callstack))) |
| 778 | msg += exc_desc |
| 779 | |
| 780 | return msg |
| 781 | |
| 782 | |
| 783 | def seconds_to_nexthour(strict=False): |
no test coverage detected