| 8601 | |
| 8602 | #if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) |
| 8603 | std::string ExceptionTranslatorRegistry::translateActiveException() const { |
| 8604 | try { |
| 8605 | #ifdef __OBJC__ |
| 8606 | // In Objective-C try objective-c exceptions first |
| 8607 | @try { |
| 8608 | return tryTranslators(); |
| 8609 | } |
| 8610 | @catch (NSException *exception) { |
| 8611 | return Catch::Detail::stringify( [exception description] ); |
| 8612 | } |
| 8613 | #else |
| 8614 | // Compiling a mixed mode project with MSVC means that CLR |
| 8615 | // exceptions will be caught in (...) as well. However, these |
| 8616 | // do not fill-in std::current_exception and thus lead to crash |
| 8617 | // when attempting rethrow. |
| 8618 | // /EHa switch also causes structured exceptions to be caught |
| 8619 | // here, but they fill-in current_exception properly, so |
| 8620 | // at worst the output should be a little weird, instead of |
| 8621 | // causing a crash. |
| 8622 | if (std::current_exception() == nullptr) { |
| 8623 | return "Non C++ exception. Possibly a CLR exception."; |
| 8624 | } |
| 8625 | return tryTranslators(); |
| 8626 | #endif |
| 8627 | } |
| 8628 | catch( TestFailureException& ) { |
| 8629 | std::rethrow_exception(std::current_exception()); |
| 8630 | } |
| 8631 | catch( std::exception& ex ) { |
| 8632 | return ex.what(); |
| 8633 | } |
| 8634 | catch( std::string& msg ) { |
| 8635 | return msg; |
| 8636 | } |
| 8637 | catch( const char* msg ) { |
| 8638 | return msg; |
| 8639 | } |
| 8640 | catch(...) { |
| 8641 | return "Unknown exception"; |
| 8642 | } |
| 8643 | } |
| 8644 | |
| 8645 | std::string ExceptionTranslatorRegistry::tryTranslators() const { |
| 8646 | if (m_translators.empty()) { |
no test coverage detected