Although this question is not limited to OpenKinect libraries, this is the best example I could offer to show this.
In C ++ Wrapper for OpenKinect, when something goes wrong, it throws a runtime_error exception. This example is from libfreenect.hpp. The thread is created in the class constructor.
// 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 simple: is it possible to somehow catch these errors and handle them?
Normally, I would handle exceptions or rewrite the code: I do not like the failure of programs due to exceptions; I would rather handle them if I knew that this was possible for them. There are several libraries that do similar things that I cannot rewrite, so why did I come to ask this question.
source share