enhancementhelp wanted
Description
Hi, I think we need to make it possible to install your own exception handler. since it is always very inconvenient to write such code (not beautiful)
TEST(ATweet, RequiresUserNameToStartWithAtSign) {
try {
throw my_custom_exception();
}
catch(const InvalidUserException& expected) {
ASSERT_STREQ("notStartingWith@", expected.what());
}
}
maybe I can write the code myself - I just have to decide how to implement it. 2 options come to my mind
- pass the exception to a custom handler function, something like this(pseudo code)
static std::function<Result(const std::exception_ptr&)> handler = nullptr;
if(handler !=nullptr) {
try{
return HandleSehExceptionsInMethodIfSupported(object, method, location);
} catch (...) {
std::exception_ptr p = std::current_exception();
handler(p) ;
}
}else{
try {
return HandleSehExceptionsInMethodIfSupported(object, method, location);
} catch (const internal::GoogleTestFailureException&) { // NOLINT
throw;
} catch (const std::exception& e) { // NOLINT
internal::ReportFailureInUnknownLocation(
TestPartResult::kFatalFailure,
FormatCxxExceptionMessage(e.what(), location));
} catch (...) { // NOLINT
// internal::ReportFailureInUnknownLocation(
// TestPartResult::kFatalFailure,
// FormatCxxExceptionMessage(NULL, location));
}
return static_cast<Result>(0);
- I like it much less - create and insert define