Last active
August 10, 2017 09:06
-
-
Save LesnyRumcajs/f2b93eec84e18271d8d40578f7cf11ca to your computer and use it in GitHub Desktop.
Exception dispatcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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