I have a C++ library which uses glog
CHECK
statements to asset various conditions on runtime. If a CHECK
fails, glog
terminates the program. My python program needs some functions from this C++ library, so I have written a simple C wrapper for those functions and compiled a dll, which I can load and use using ctypes
.
The problem is, if a CHECK
statement fails, the python program is immediately aborted and the user loses all unsaved work!
Instead I would like to handle cases where something went wrong in the library as exceptions in python. The C++ library is not written by me and rewriting it is not a good solution. How can I prevent my python program from being terminated when a glog
CHECK
statement fails in the C++ library called from it?