MCPcopy Index your code
hub / github.com/python/cpython / do_exceptions

Method do_exceptions

Lib/pdb.py:1767–1812  ·  view source on GitHub ↗

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 an integer as arg

(self, arg)

Source from the content-addressed store, hash-verified

1765 self.lineno = None
1766
1767 def do_exceptions(self, arg):
1768 """exceptions [number]
1769
1770 List or change current exception in an exception chain.
1771
1772 Without arguments, list all the current exception in the exception
1773 chain. Exceptions will be numbered, with the current exception indicated
1774 with an arrow.
1775
1776 If given an integer as argument, switch to the exception at that index.
1777 """
1778 if not self._chained_exceptions:
1779 self.message(
1780 "Did not find chained exceptions. To move between"
1781 " exceptions, pdb/post_mortem must be given an exception"
1782 " object rather than a traceback."
1783 )
1784 return
1785 if not arg:
1786 for ix, exc in enumerate(self._chained_exceptions):
1787 prompt = ">" if ix == self._chained_exception_index else " "
1788 rep = repr(exc)
1789 if len(rep) > 80:
1790 rep = rep[:77] + "..."
1791 indicator = (
1792 " -"
1793 if self._chained_exceptions[ix].__traceback__ is None
1794 else f"{ix:>3}"
1795 )
1796 self.message(f"{prompt} {indicator} {rep}")
1797 else:
1798 try:
1799 number = int(arg)
1800 except ValueError:
1801 self.error("Argument must be an integer")
1802 return
1803 if 0 <= number < len(self._chained_exceptions):
1804 if self._chained_exceptions[number].__traceback__ is None:
1805 self.error("This exception does not have a traceback, cannot jump to it")
1806 return
1807
1808 self._chained_exception_index = number
1809 self.setup(None, self._chained_exceptions[number].__traceback__)
1810 self.print_stack_entry(self.stack[self.curindex])
1811 else:
1812 self.error("No exception with that number")
1813
1814 def do_up(self, arg):
1815 """u(p) [count]

Callers

nothing calls this directly

Calls 5

messageMethod · 0.95
errorMethod · 0.95
setupMethod · 0.95
print_stack_entryMethod · 0.95
enumerateFunction · 0.85

Tested by

no test coverage detected