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)
| 160 | |
| 161 | |
| 162 | def 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. |
no test coverage detected