A chain of exceptions, separated by descriptions (e.g. "The above exception was the direct cause of the following exception").
| 1294 | |
| 1295 | @dataclasses.dataclass(eq=False) |
| 1296 | class ExceptionChainRepr(ExceptionRepr): |
| 1297 | """A chain of exceptions, separated by descriptions (e.g. "The above |
| 1298 | exception was the direct cause of the following exception").""" |
| 1299 | |
| 1300 | chain: Sequence[tuple[ReprTraceback, ReprFileLocation | None, str | None]] |
| 1301 | |
| 1302 | def __init__( |
| 1303 | self, |
| 1304 | chain: Sequence[tuple[ReprTraceback, ReprFileLocation | None, str | None]], |
| 1305 | ) -> None: |
| 1306 | # reprcrash and reprtraceback of the outermost (the newest) exception |
| 1307 | # in the chain. |
| 1308 | super().__init__( |
| 1309 | reprtraceback=chain[-1][0], |
| 1310 | reprcrash=chain[-1][1], |
| 1311 | ) |
| 1312 | self.chain = chain |
| 1313 | |
| 1314 | def toterminal(self, tw: TerminalWriter) -> None: |
| 1315 | for reprtraceback, reprcrash, description in self.chain: |
| 1316 | reprtraceback.toterminal(tw) |
| 1317 | if description is not None: |
| 1318 | tw.line("") |
| 1319 | tw.line(description, yellow=True) |
| 1320 | super().toterminal(tw) |
| 1321 | |
| 1322 | |
| 1323 | @dataclasses.dataclass(eq=False) |
no outgoing calls
no test coverage detected