While this question isn't limited to the OpenKinect Libraries, it is the best example I could come up with for showing this off.
In the C++ Wrapper for OpenKinect, whenever something goes wrong it throws a runtime_error exception. This example is from libfreenect.hpp. The thread is created in the constructor of the class.
// Do not call directly, thread runs here
void operator()() {
while(!m_stop) {
if(freenect_process_events(m_ctx) < 0) throw std::runtime_error("Cannot process freenect events");
}
}
static void *pthread_callback(void *user_data) {
Freenect* freenect = static_cast<Freenect*>(user_data);
(*freenect)();
return NULL;
}
My question is simply: is it possible to catch these errors somehow and handle them?
Ordinarily, I would handle the exceptions, or rewrite the code: I don't like having programs crash because of exceptions, I would rather handle them cleanly if I know it is possible for them to occur. There are some libraries that do similar things that I cannot rewrite, hence why I came around to asking this question.