Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/internal
diff options
context:
space:
mode:
authorMartin Hořeňovský2021-08-06 00:34:22 +0200
committerMartin Hořeňovský2021-08-06 00:56:09 +0200
commit02ab64da2e924ba9dbae3dc3e1f6357041d1b037 (patch)
tree17da43b4d95728c2f6e48ecdb6ce69d5fcf95dc0 /src/catch2/internal
parent77df08b44d3527e472048b8fdac98ea82c343fbf (diff)
downloadcatch3-02ab64da2e924ba9dbae3dc3e1f6357041d1b037.tar.gz
Cleanup ExceptionTranslatorRegistry::translateActiveException
Diffstat (limited to 'src/catch2/internal')
-rw-r--r--src/catch2/internal/catch_exception_translator_registry.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/catch2/internal/catch_exception_translator_registry.cpp b/src/catch2/internal/catch_exception_translator_registry.cpp
index 52831fc5..08d5d8ef 100644
--- a/src/catch2/internal/catch_exception_translator_registry.cpp
+++ b/src/catch2/internal/catch_exception_translator_registry.cpp
@@ -21,27 +21,32 @@ namespace Catch {
#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
std::string ExceptionTranslatorRegistry::translateActiveException() const {
+ // Compiling a mixed mode project with MSVC means that CLR
+ // exceptions will be caught in (...) as well. However, these do
+ // do not fill-in std::current_exception and thus lead to crash
+ // when attempting rethrow.
+ // /EHa switch also causes structured exceptions to be caught
+ // here, but they fill-in current_exception properly, so
+ // at worst the output should be a little weird, instead of
+ // causing a crash.
+ if ( std::current_exception() == nullptr ) {
+ return "Non C++ exception. Possibly a CLR exception.";
+ }
+
+ // First we try user-registered translators. If none of them can
+ // handle the exception, it will be rethrown handled by our defaults.
try {
- // Compiling a mixed mode project with MSVC means that CLR
- // exceptions will be caught in (...) as well. However, these
- // do not fill-in std::current_exception and thus lead to crash
- // when attempting rethrow.
- // /EHa switch also causes structured exceptions to be caught
- // here, but they fill-in current_exception properly, so
- // at worst the output should be a little weird, instead of
- // causing a crash.
- if (std::current_exception() == nullptr) {
- return "Non C++ exception. Possibly a CLR exception.";
- }
return tryTranslators();
}
+ // To avoid having to handle TFE explicitly everywhere, we just
+ // rethrow it so that it goes back up the caller.
catch( TestFailureException& ) {
std::rethrow_exception(std::current_exception());
}
- catch( std::exception& ex ) {
+ catch( std::exception const& ex ) {
return ex.what();
}
- catch( std::string& msg ) {
+ catch( std::string const& msg ) {
return msg;
}
catch( const char* msg ) {