MCPcopy
hub / github.com/pyload/pyload / format_exc

Function format_exc

module/plugins/internal/misc.py:757–780  ·  view source on GitHub ↗

Format call-stack and display exception information (if availible)

(frame=None)

Source from the content-addressed store, hash-verified

755
756
757def 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
783def seconds_to_nexthour(strict=False):

Callers 5

_print_excMethod · 0.70
getDebugDumpMethod · 0.50
runMethod · 0.50
get_infoMethod · 0.50
call_apiFunction · 0.50

Calls 4

exc_infoMethod · 0.80
extendMethod · 0.80
joinMethod · 0.80
decodeFunction · 0.70

Tested by

no test coverage detected