##// END OF EJS Templates
update set_custom_exc docstring with new-style Parameters section
MinRK -
Show More
@@ -1447,29 +1447,37 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 ----------
1454
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
1458 LIST here, because of the way Python's except statement works. If
1459 you only want to trap a single exception, use a singleton tuple::
1460
1461 exc_tuple == (MyCustomException,)
1453 1462
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
1456 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:
1463 handler : callable
1464 handler must have the following signature::
1458 1465
1459 exc_tuple == (MyCustomException,)
1466 def my_handler(self, etype, value, tb, tb_offset=None):
1467 ...
1468 return structured_traceback
1460 1469
1461 - handler: this must be defined as a function with the following
1462 basic interface::
1470 Your handler must return a structured traceback (a list of strings),
1471 or None.
1463 1472
1464 def my_handler(self, etype, value, tb, tb_offset=None)
1465 ...
1466 # The return value must be
1467 return structured_traceback
1473 This will be made into an instance method (via types.MethodType)
1474 of IPython itself, and it will be called if any of the exceptions
1475 listed in the exc_tuple are caught. If the handler is None, an
1476 internal basic one is used, which just prints basic info.
1468 1477
1469 This will be made into an instance method (via types.MethodType)
1470 of IPython itself, and it will be called if any of the exceptions
1471 listed in the exc_tuple are caught. If the handler is None, an
1472 internal basic one is used, which just prints basic info.
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.
1473 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
General Comments 0
You need to be logged in to leave comments. Login now