exceptions [number] List or change current exception in an exception chain. Without arguments, list all the current exception in the exception chain. Exceptions will be numbered, with the current exception indicated with an arrow. If given
(self, arg)
| 488 | self._chained_exception_index = 0 |
| 489 | |
| 490 | def do_exceptions(self, arg): |
| 491 | """exceptions [number] |
| 492 | List or change current exception in an exception chain. |
| 493 | Without arguments, list all the current exception in the exception |
| 494 | chain. Exceptions will be numbered, with the current exception indicated |
| 495 | with an arrow. |
| 496 | If given an integer as argument, switch to the exception at that index. |
| 497 | ``exception`` can be used as an alias for this command. |
| 498 | """ |
| 499 | if not self._chained_exceptions: |
| 500 | self.message( |
| 501 | "Did not find chained exceptions. To move between" |
| 502 | " exceptions, pdb/post_mortem must be given an exception" |
| 503 | " object rather than a traceback." |
| 504 | ) |
| 505 | return |
| 506 | if not arg: |
| 507 | for ix, exc in enumerate(self._chained_exceptions): |
| 508 | prompt = ">" if ix == self._chained_exception_index else " " |
| 509 | rep = repr(exc) |
| 510 | if len(rep) > 80: |
| 511 | rep = rep[:77] + "..." |
| 512 | indicator = ( |
| 513 | " -" |
| 514 | if self._chained_exceptions[ix].__traceback__ is None |
| 515 | else f"{ix:>3}" |
| 516 | ) |
| 517 | self.message(f"{prompt} {indicator} {rep}") |
| 518 | else: |
| 519 | try: |
| 520 | number = int(arg) |
| 521 | except ValueError: |
| 522 | self.error("Argument must be an integer") |
| 523 | return |
| 524 | if 0 <= number < len(self._chained_exceptions): |
| 525 | if self._chained_exceptions[number].__traceback__ is None: |
| 526 | self.error( |
| 527 | "This exception does not have a traceback, cannot jump to it" |
| 528 | ) |
| 529 | return |
| 530 | |
| 531 | self._chained_exception_index = number |
| 532 | self.setup(None, self._chained_exceptions[number].__traceback__) |
| 533 | self.print_stack_entry(self.stack[self.curindex]) |
| 534 | else: |
| 535 | self.error("No exception with that number") |
| 536 | |
| 537 | def do_exception(self, arg): |
| 538 | """exception [number] |
no test coverage detected