The above controller seems to support also C++. You could just use C++ rather than C, doing some minor changes to your C code and use the try/catch as you want.