%exception OpenMM::Platform_registerPlatform_cuda { try { $action } catch (OpenMM::OpenMMException &e) { PyErr_SetString(PyExc_Exception, const_cast(e.what())); return NULL; } }