Recipe 20-1. Catching Exceptions from Anywhere
Problem
If you use wxPython a lot, you will soon realize that some exceptions are difficult to catch. The reason it is so difficult is because wxPython is a wrapper around a C++ package called
wxWidgets
. Thus you have a mixture of C++ and Python in your application. What this means is that events bubble up from C++ to Python and back again. Where an exception occurs (the C++ side or the Python side) determines whether or not we will be able to catch it.
Solution
One solution that works in a lot of cases is using Python’s
sys.excepthook
. We’ll spend ...