Skip to content

Instantly share code, notes, and snippets.

@LesnyRumcajs
Last active August 10, 2017 09:06
Show Gist options
  • Save LesnyRumcajs/f2b93eec84e18271d8d40578f7cf11ca to your computer and use it in GitHub Desktop.
Save LesnyRumcajs/f2b93eec84e18271d8d40578f7cf11ca to your computer and use it in GitHub Desktop.
Exception dispatcher
#ifndef CATCH_WRAPPER
#define CATCH_WRAPPER
template <class T, void (T::*FUNC)()>
class CatchWrapper {
public:
static int wrap(T* instance) {
int ret(-1);
try {
(instance->*FUNC)();
ret = 0;
}
catch (const std::exception& ex) {
// handle this
}
catch (...) {
// ... and anything else
}
return ret;
}
};
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment