MCPcopy Create free account
hub / github.com/ChaiScript/ChaiScript / translateActiveException

Method translateActiveException

unittests/catch.hpp:7251–7291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7249 }
7250
7251 std::string ExceptionTranslatorRegistry::translateActiveException() const {
7252 try {
7253#ifdef __OBJC__
7254 // In Objective-C try objective-c exceptions first
7255 @try {
7256 return tryTranslators();
7257 }
7258 @catch (NSException *exception) {
7259 return Catch::Detail::stringify( [exception description] );
7260 }
7261#else
7262 // Compiling a mixed mode project with MSVC means that CLR
7263 // exceptions will be caught in (...) as well. However, these
7264 // do not fill-in std::current_exception and thus lead to crash
7265 // when attempting rethrow.
7266 // /EHa switch also causes structured exceptions to be caught
7267 // here, but they fill-in current_exception properly, so
7268 // at worst the output should be a little weird, instead of
7269 // causing a crash.
7270 if (std::current_exception() == nullptr) {
7271 return "Non C++ exception. Possibly a CLR exception.";
7272 }
7273 return tryTranslators();
7274#endif
7275 }
7276 catch( TestFailureException& ) {
7277 std::rethrow_exception(std::current_exception());
7278 }
7279 catch( std::exception& ex ) {
7280 return ex.what();
7281 }
7282 catch( std::string& msg ) {
7283 return msg;
7284 }
7285 catch( const char* msg ) {
7286 return msg;
7287 }
7288 catch(...) {
7289 return "Unknown exception";
7290 }
7291 }
7292
7293 std::string ExceptionTranslatorRegistry::tryTranslators() const {
7294 if( m_translators.empty() )

Callers 1

translateActiveExceptionFunction · 0.80

Calls 2

stringifyFunction · 0.85
whatMethod · 0.45

Tested by

no test coverage detected