MCPcopy Create free account
hub / github.com/BVLC/caffe / HandleExceptionsInMethodIfSupported

Function HandleExceptionsInMethodIfSupported

src/gtest/gtest-all.cpp:3401–3450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3399// Result in case of an SEH exception.
3400template <class T, typename Result>
3401Result HandleExceptionsInMethodIfSupported(
3402 T* object, Result (T::*method)(), const char* location) {
3403 // NOTE: The user code can affect the way in which Google Test handles
3404 // exceptions by setting GTEST_FLAG(catch_exceptions), but only before
3405 // RUN_ALL_TESTS() starts. It is technically possible to check the flag
3406 // after the exception is caught and either report or re-throw the
3407 // exception based on the flag's value:
3408 //
3409 // try {
3410 // // Perform the test method.
3411 // } catch (...) {
3412 // if (GTEST_FLAG(catch_exceptions))
3413 // // Report the exception as failure.
3414 // else
3415 // throw; // Re-throws the original exception.
3416 // }
3417 //
3418 // However, the purpose of this flag is to allow the program to drop into
3419 // the debugger when the exception is thrown. On most platforms, once the
3420 // control enters the catch block, the exception origin information is
3421 // lost and the debugger will stop the program at the point of the
3422 // re-throw in this function -- instead of at the point of the original
3423 // throw statement in the code under test. For this reason, we perform
3424 // the check early, sacrificing the ability to affect Google Test's
3425 // exception handling in the method where the exception is thrown.
3426 if (internal::GetUnitTestImpl()->catch_exceptions()) {
3427#if GTEST_HAS_EXCEPTIONS
3428 try {
3429 return HandleSehExceptionsInMethodIfSupported(object, method, location);
3430 } catch (const GoogleTestFailureException&) { // NOLINT
3431 // This exception doesn't originate in code under test. It makes no
3432 // sense to report it as a test failure.
3433 throw;
3434 } catch (const std::exception& e) { // NOLINT
3435 internal::ReportFailureInUnknownLocation(
3436 TestPartResult::kFatalFailure,
3437 FormatCxxExceptionMessage(e.what(), location));
3438 } catch (...) { // NOLINT
3439 internal::ReportFailureInUnknownLocation(
3440 TestPartResult::kFatalFailure,
3441 FormatCxxExceptionMessage(NULL, location));
3442 }
3443 return static_cast<Result>(0);
3444#else
3445 return HandleSehExceptionsInMethodIfSupported(object, method, location);
3446#endif // GTEST_HAS_EXCEPTIONS
3447 } else {
3448 return (object->*method)();
3449 }
3450}
3451
3452} // namespace internal
3453

Callers 1

RunMethod · 0.85

Tested by

no test coverage detected