MCPcopy Index your code
hub / github.com/ipython/ipython / format_exception_as_a_whole

Method format_exception_as_a_whole

IPython/core/ultratb.py:781–852  ·  view source on GitHub ↗

Formats the header, traceback and exception message for a single exception. This may be called multiple times by Python 3 exception chaining (PEP 3134).

(
        self,
        etype: type,
        evalue: Optional[BaseException],
        etb: Optional[TracebackType],
        context: int,
        tb_offset: Optional[int],
    )

Source from the content-addressed store, hash-verified

779 ]
780
781 def format_exception_as_a_whole(
782 self,
783 etype: type,
784 evalue: Optional[BaseException],
785 etb: Optional[TracebackType],
786 context: int,
787 tb_offset: Optional[int],
788 ) -> list[list[str]]:
789 """Formats the header, traceback and exception message for a single exception.
790
791 This may be called multiple times by Python 3 exception chaining
792 (PEP 3134).
793 """
794 # some locals
795 orig_etype = etype
796 try:
797 etype = etype.__name__ # type: ignore[assignment]
798 except AttributeError:
799 pass
800
801 tb_offset = self.tb_offset if tb_offset is None else tb_offset
802 assert isinstance(tb_offset, int)
803 head = self.prepare_header(str(etype), self.long_header)
804 records = self.get_records(etb, context, tb_offset) if etb else []
805
806 frames = []
807 skipped = 0
808 lastrecord = len(records) - 1
809 for i, record in enumerate(records):
810 if (
811 not isinstance(record._sd, stack_data.RepeatedFrames)
812 and self.skip_hidden
813 ):
814 if (
815 record.frame.f_locals.get("__tracebackhide__", 0)
816 and i != lastrecord
817 ):
818 skipped += 1
819 continue
820 if skipped:
821 frames.append(
822 theme_table[self._theme_name].format(
823 [
824 (Token, " "),
825 (Token.ExcName, "[... skipping hidden %s frame]" % skipped),
826 (Token, "\n"),
827 ]
828 )
829 )
830 skipped = 0
831 frames.append(self.format_record(record))
832 if skipped:
833 frames.append(
834 theme_table[self._theme_name].format(
835 [
836 (Token, " "),
837 (Token.ExcName, "[... skipping hidden %s frame]" % skipped),
838 (Token, "\n"),

Callers 1

structured_tracebackMethod · 0.95

Calls 7

prepare_headerMethod · 0.95
get_recordsMethod · 0.95
format_recordMethod · 0.95
format_exceptionMethod · 0.95
get_ipythonFunction · 0.90
getMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected