From eff28b54416dc0a68dd48c50c1d4ffd6c5386bc9 Mon Sep 17 00:00:00 2001 From: parth0809 Date: Fri, 26 Jan 2024 18:04:37 +0530 Subject: [PATCH] Better exception printing for multi-line exceptions --- googletest/src/gtest.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 7dc80594..411c2f03 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -2581,7 +2581,17 @@ static std::string FormatCxxExceptionMessage(const char* description, const char* location) { Message message; if (description != nullptr) { - message << "C++ exception with description \"" << description << "\""; + std::string desc; + const char *ch; + for(ch=description;*ch!='\0';ch++) + { + if(*ch=='\n') + desc+="\n>"; + else + desc+=*ch; + } + description=desc.c_str(); + message << "C++ exception with description \n" << description << "\n"; } else { message << "Unknown C++ exception"; }