Better exception printing for multi-line exceptions #4387

This commit is contained in:
Abhinav Pratap 2023-10-15 01:08:49 +05:30 committed by GitHub
parent 2dd1c13195
commit bdbec629fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2571,7 +2571,14 @@ static std::string FormatCxxExceptionMessage(const char* description,
const char* location) {
Message message;
if (description != nullptr) {
message << "C++ exception with description \"" << description << "\"";
std::string desc(description);
if (desc.find('\n') == std::string::npos) {
message << "C++ exception with description \"" << desc << "\"";
} else {
message << "C++ exception with description\n> ";
std::replace(desc.begin(), desc.end(), '\n', '\n> ');
message << desc;
}
} else {
message << "Unknown C++ exception";
}
@ -2580,6 +2587,7 @@ static std::string FormatCxxExceptionMessage(const char* description,
return message.GetString();
}
static std::string PrintTestPartResultToString(
const TestPartResult& test_part_result);