Extended exception handling
- Dominant language
- C++
- Stars
- 39.5k
- Forks
- 10.9k
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 1
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
1) pass the exception to a custom handler function, something like this(pseudo code)
```
static std::function 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(0);
```
2) I like it much less - create and insert define
Contributor guide
Research direction
Start by reviewing the existing exception handling around HandleSehExceptionsInMethodIfSupported, including the paths described in the issue. Define the supported custom-handler behavior and implementation approach, then verify that installed handlers receive exceptions without breaking the existing GoogleTest failure handling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100