##// END OF EJS Templates
update set_custom_exc docstring with new-style Parameters section
MinRK -
Show More
@@ -1447,30 +1447,38 b' class InteractiveShell(SingletonConfigurable, Magic):'
1447 1447
1448 1448 Set a custom exception handler, which will be called if any of the
1449 1449 exceptions in exc_tuple occur in the mainloop (specifically, in the
1450 run_code() method.
1450 run_code() method).
1451 1451
1452 Inputs:
1452 Parameters
1453 ----------
1453 1454
1454 - exc_tuple: a *tuple* of valid exceptions to call the defined
1455 handler for. It is very important that you use a tuple, and NOT A
1455 exc_tuple : tuple of exception classes
1456 A *tuple* of exception classes, for which to call the defined
1457 handler. It is very important that you use a tuple, and NOT A
1456 1458 LIST here, because of the way Python's except statement works. If
1457 you only want to trap a single exception, use a singleton tuple:
1459 you only want to trap a single exception, use a singleton tuple::
1458 1460
1459 1461 exc_tuple == (MyCustomException,)
1460 1462
1461 - handler: this must be defined as a function with the following
1462 basic interface::
1463 handler : callable
1464 handler must have the following signature::
1463 1465
1464 def my_handler(self, etype, value, tb, tb_offset=None)
1466 def my_handler(self, etype, value, tb, tb_offset=None):
1465 1467 ...
1466 # The return value must be
1467 1468 return structured_traceback
1468 1469
1470 Your handler must return a structured traceback (a list of strings),
1471 or None.
1472
1469 1473 This will be made into an instance method (via types.MethodType)
1470 1474 of IPython itself, and it will be called if any of the exceptions
1471 1475 listed in the exc_tuple are caught. If the handler is None, an
1472 1476 internal basic one is used, which just prints basic info.
1473 1477
1478 To protect IPython from crashes, if your handler ever raises an
1479 exception or returns an invalid result, it will be immediately
1480 disabled.
1481
1474 1482 WARNING: by putting in your own exception handler into IPython's main
1475 1483 execution loop, you run a very good chance of nasty crashes. This
1476 1484 facility should only be used if you really know what you are doing."""
General Comments 0
You need to be logged in to leave comments. Login now