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

Method structured_traceback

IPython/core/ultratb.py:1127–1168  ·  view source on GitHub ↗
(
        self,
        etype: type,
        evalue: BaseException | None,
        etb: TracebackType | None = None,
        tb_offset: int | None = None,
        context: int = 5,
    )

Source from the content-addressed store, hash-verified

1125 self.set_mode(mode)
1126
1127 def structured_traceback(
1128 self,
1129 etype: type,
1130 evalue: BaseException | None,
1131 etb: TracebackType | None = None,
1132 tb_offset: int | None = None,
1133 context: int = 5,
1134 ) -> list[str]:
1135 tb_offset = self.tb_offset if tb_offset is None else tb_offset
1136 mode = self.mode
1137 if mode in self.verbose_modes:
1138 # Verbose modes need a full traceback
1139 return VerboseTB.structured_traceback(
1140 self, etype, evalue, etb, tb_offset, context
1141 )
1142 elif mode == "Docs":
1143 # return DocTB
1144 return DocTB(
1145 theme_name=self._theme_name,
1146 call_pdb=self.call_pdb,
1147 ostream=self.ostream,
1148 tb_offset=tb_offset,
1149 long_header=self.long_header,
1150 include_vars=self.include_vars,
1151 check_cache=self.check_cache,
1152 debugger_cls=self.debugger_cls,
1153 ).structured_traceback(
1154 etype, evalue, etb, tb_offset, 1
1155 ) # type: ignore[arg-type]
1156
1157 elif mode == "Minimal":
1158 return ListTB.get_exception_only(self, etype, evalue)
1159 elif mode == "Doctest":
1160 return ListTB.structured_traceback_doctest(self, etype, evalue, etb, tb_offset, context)
1161 else:
1162 # We must check the source cache because otherwise we can print
1163 # out-of-date source code.
1164 self.check_cache()
1165 # Now we can extract and format the exception
1166 return ListTB.structured_traceback(
1167 self, etype, evalue, etb, tb_offset, context
1168 )
1169
1170 def stb2text(self, stb: list[str]) -> str:
1171 """Convert a structured traceback (a list) to a string."""

Callers

nothing calls this directly

Calls 4

DocTBClass · 0.85
structured_tracebackMethod · 0.45
get_exception_onlyMethod · 0.45

Tested by

no test coverage detected