MCPcopy Index your code
hub / github.com/RustPython/RustPython / format_exception_only

Function format_exception_only

Lib/traceback.py:162–181  ·  view source on GitHub ↗

Format the exception part of a traceback. The return value is a list of strings, each ending in a newline. The list contains the exception's message, which is normally a single string; however, for :exc:`SyntaxError` exceptions, it contains several lines that (when printed) display

(exc, /, value=_sentinel, *, show_group=False, **kwargs)

Source from the content-addressed store, hash-verified

160
161
162def format_exception_only(exc, /, value=_sentinel, *, show_group=False, **kwargs):
163 """Format the exception part of a traceback.
164
165 The return value is a list of strings, each ending in a newline.
166
167 The list contains the exception's message, which is
168 normally a single string; however, for :exc:`SyntaxError` exceptions, it
169 contains several lines that (when printed) display detailed information
170 about where the syntax error occurred. Following the message, the list
171 contains the exception's ``__notes__``.
172
173 When *show_group* is ``True``, and the exception is an instance of
174 :exc:`BaseExceptionGroup`, the nested exceptions are included as
175 well, recursively, with indentation relative to their nesting depth.
176 """
177 colorize = kwargs.get("colorize", False)
178 if value is _sentinel:
179 value = exc
180 te = TracebackException(type(value), value, None, compact=True)
181 return list(te.format_exception_only(show_group=show_group, colorize=colorize))
182
183
184# -- not official API but folk probably use these two functions.

Callers 1

html_errorFunction · 0.90

Calls 4

format_exception_onlyMethod · 0.95
listClass · 0.85
TracebackExceptionClass · 0.70
getMethod · 0.45

Tested by

no test coverage detected