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)
| 170 | |
| 171 | |
| 172 | def format_exception_only(exc, /, value=_sentinel, *, show_group=False, **kwargs): |
| 173 | """Format the exception part of a traceback. |
| 174 | |
| 175 | The return value is a list of strings, each ending in a newline. |
| 176 | |
| 177 | The list contains the exception's message, which is |
| 178 | normally a single string; however, for :exc:`SyntaxError` exceptions, it |
| 179 | contains several lines that (when printed) display detailed information |
| 180 | about where the syntax error occurred. Following the message, the list |
| 181 | contains the exception's ``__notes__``. |
| 182 | |
| 183 | When *show_group* is ``True``, and the exception is an instance of |
| 184 | :exc:`BaseExceptionGroup`, the nested exceptions are included as |
| 185 | well, recursively, with indentation relative to their nesting depth. |
| 186 | """ |
| 187 | colorize = kwargs.get("colorize", False) |
| 188 | if value is _sentinel: |
| 189 | value = exc |
| 190 | te = TracebackException(type(value), value, None, compact=True) |
| 191 | return list(te.format_exception_only(show_group=show_group, colorize=colorize)) |
| 192 | |
| 193 | |
| 194 | # -- not official API but folk probably use these two functions. |
no test coverage detected
searching dependent graphs…