MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / format_exception_only

Function format_exception_only

tools/python-3.11.9-amd64/Lib/traceback.py:143–157  ·  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) d

(exc, /, value=_sentinel)

Source from the content-addressed store, hash-verified

141
142
143def format_exception_only(exc, /, value=_sentinel):
144 """Format the exception part of a traceback.
145
146 The return value is a list of strings, each ending in a newline.
147
148 The list contains the exception's message, which is
149 normally a single string; however, for :exc:`SyntaxError` exceptions, it
150 contains several lines that (when printed) display detailed information
151 about where the syntax error occurred. Following the message, the list
152 contains the exception's ``__notes__``.
153 """
154 if value is _sentinel:
155 value = exc
156 te = TracebackException(type(value), value, None, compact=True)
157 return list(te.format_exception_only())
158
159
160# -- not official API but folk probably use these two functions.

Callers 1

html_errorFunction · 0.90

Calls 4

format_exception_onlyMethod · 0.95
listFunction · 0.85
TracebackExceptionClass · 0.70
typeClass · 0.50

Tested by

no test coverage detected