| 7082 | } |
| 7083 | |
| 7084 | std::string ExceptionTranslatorRegistry::translateActiveException() const { |
| 7085 | try { |
| 7086 | #ifdef __OBJC__ |
| 7087 | // In Objective-C try objective-c exceptions first |
| 7088 | @try { |
| 7089 | return tryTranslators(); |
| 7090 | } @catch (NSException *exception) { |
| 7091 | return Catch::Detail::stringify([exception description]); |
| 7092 | } |
| 7093 | #else |
| 7094 | // Compiling a mixed mode project with MSVC means that CLR |
| 7095 | // exceptions will be caught in (...) as well. However, these |
| 7096 | // do not fill-in std::current_exception and thus lead to crash |
| 7097 | // when attempting rethrow. |
| 7098 | // /EHa switch also causes structured exceptions to be caught |
| 7099 | // here, but they fill-in current_exception properly, so |
| 7100 | // at worst the output should be a little weird, instead of |
| 7101 | // causing a crash. |
| 7102 | if (std::current_exception() == nullptr) { |
| 7103 | return "Non C++ exception. Possibly a CLR exception."; |
| 7104 | } |
| 7105 | return tryTranslators(); |
| 7106 | #endif |
| 7107 | } catch (TestFailureException &) { |
| 7108 | std::rethrow_exception(std::current_exception()); |
| 7109 | } catch (std::exception &ex) { |
| 7110 | return ex.what(); |
| 7111 | } catch (std::string &msg) { |
| 7112 | return msg; |
| 7113 | } catch (const char *msg) { |
| 7114 | return msg; |
| 7115 | } catch (...) { |
| 7116 | return "Unknown exception"; |
| 7117 | } |
| 7118 | } |
| 7119 | |
| 7120 | std::string ExceptionTranslatorRegistry::tryTranslators() const { |
| 7121 | if (m_translators.empty()) |
no test coverage detected