Format a stack trace and the exception information. The arguments have the same meaning as the corresponding arguments to print_exception(). The return value is a list of strings, each ending in a newline and some containing internal newlines. When these lines are concatenate
(exc, /, value=_sentinel, tb=_sentinel, limit=None, \
chain=True)
| 126 | |
| 127 | |
| 128 | def format_exception(exc, /, value=_sentinel, tb=_sentinel, limit=None, \ |
| 129 | chain=True): |
| 130 | """Format a stack trace and the exception information. |
| 131 | |
| 132 | The arguments have the same meaning as the corresponding arguments |
| 133 | to print_exception(). The return value is a list of strings, each |
| 134 | ending in a newline and some containing internal newlines. When |
| 135 | these lines are concatenated and printed, exactly the same text is |
| 136 | printed as does print_exception(). |
| 137 | """ |
| 138 | value, tb = _parse_value_tb(exc, value, tb) |
| 139 | te = TracebackException(type(value), value, tb, limit=limit, compact=True) |
| 140 | return list(te.format(chain=chain)) |
| 141 | |
| 142 | |
| 143 | def format_exception_only(exc, /, value=_sentinel): |
no test coverage detected