Use C++ exception mechanism