mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-30 01:03:30 +01:00
Cleanup ExceptionTranslatorRegistry::translateActiveException
This commit is contained in:
parent
77df08b44d
commit
02ab64da2e
@ -21,9 +21,8 @@ namespace Catch {
|
|||||||
|
|
||||||
#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
|
#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
|
||||||
std::string ExceptionTranslatorRegistry::translateActiveException() const {
|
std::string ExceptionTranslatorRegistry::translateActiveException() const {
|
||||||
try {
|
|
||||||
// Compiling a mixed mode project with MSVC means that CLR
|
// Compiling a mixed mode project with MSVC means that CLR
|
||||||
// exceptions will be caught in (...) as well. However, these
|
// exceptions will be caught in (...) as well. However, these do
|
||||||
// do not fill-in std::current_exception and thus lead to crash
|
// do not fill-in std::current_exception and thus lead to crash
|
||||||
// when attempting rethrow.
|
// when attempting rethrow.
|
||||||
// /EHa switch also causes structured exceptions to be caught
|
// /EHa switch also causes structured exceptions to be caught
|
||||||
@ -33,15 +32,21 @@ namespace Catch {
|
|||||||
if ( std::current_exception() == nullptr ) {
|
if ( std::current_exception() == nullptr ) {
|
||||||
return "Non C++ exception. Possibly a CLR exception.";
|
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 {
|
||||||
return tryTranslators();
|
return tryTranslators();
|
||||||
}
|
}
|
||||||
|
// To avoid having to handle TFE explicitly everywhere, we just
|
||||||
|
// rethrow it so that it goes back up the caller.
|
||||||
catch( TestFailureException& ) {
|
catch( TestFailureException& ) {
|
||||||
std::rethrow_exception(std::current_exception());
|
std::rethrow_exception(std::current_exception());
|
||||||
}
|
}
|
||||||
catch( std::exception& ex ) {
|
catch( std::exception const& ex ) {
|
||||||
return ex.what();
|
return ex.what();
|
||||||
}
|
}
|
||||||
catch( std::string& msg ) {
|
catch( std::string const& msg ) {
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
catch( const char* msg ) {
|
catch( const char* msg ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user