Print the last traceback. Optionally, specify an exception reporting mode, tuning the verbosity of the traceback. By default the currently-active exception mode is used. See %xmode for changing exception reporting modes. Valid modes: Plain, Context, Verbose, and Min
(self, s)
| 492 | |
| 493 | @line_magic |
| 494 | def tb(self, s): |
| 495 | """Print the last traceback. |
| 496 | |
| 497 | Optionally, specify an exception reporting mode, tuning the |
| 498 | verbosity of the traceback. By default the currently-active exception |
| 499 | mode is used. See %xmode for changing exception reporting modes. |
| 500 | |
| 501 | Valid modes: Plain, Context, Verbose, and Minimal. |
| 502 | """ |
| 503 | interactive_tb = self.shell.InteractiveTB |
| 504 | if s: |
| 505 | # Switch exception reporting mode for this one call. |
| 506 | # Ensure it is switched back. |
| 507 | def xmode_switch_err(name): |
| 508 | warn('Error changing %s exception modes.\n%s' % |
| 509 | (name,sys.exc_info()[1])) |
| 510 | |
| 511 | new_mode = s.strip().capitalize() |
| 512 | original_mode = interactive_tb.mode |
| 513 | try: |
| 514 | try: |
| 515 | interactive_tb.set_mode(mode=new_mode) |
| 516 | except Exception: |
| 517 | xmode_switch_err('user') |
| 518 | else: |
| 519 | self.shell.showtraceback() |
| 520 | finally: |
| 521 | interactive_tb.set_mode(mode=original_mode) |
| 522 | else: |
| 523 | self.shell.showtraceback() |
| 524 | |
| 525 | @skip_doctest |
| 526 | @line_magic |
nothing calls this directly
no test coverage detected