diff options
Diffstat (limited to 'doctest/parts/doctest_impl.h')
-rw-r--r-- | doctest/parts/doctest_impl.h | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/doctest/parts/doctest_impl.h b/doctest/parts/doctest_impl.h index f67ee88..3e9d735 100644 --- a/doctest/parts/doctest_impl.h +++ b/doctest/parts/doctest_impl.h @@ -996,20 +996,24 @@ namespace detail String translateActiveException() { #ifndef DOCTEST_CONFIG_NO_EXCEPTIONS - ExceptionTranslatorResult res; + String res; std::vector<const IExceptionTranslator*>& translators = getExceptionTranslators(); - for(size_t i = 0; i < translators.size() && res.success == false; ++i) - res = translators[i]->translate(); - if(res.success == false) { - try { - throw; - } catch(TestFailureException&) { throw; } catch(std::exception& ex) { - res.result = ex.what(); - } catch(std::string& msg) { res.result = msg.c_str(); } catch(const char* msg) { - res.result = msg; - } catch(...) { res.result = "unknown exception"; } + for(size_t i = 0; i < translators.size(); ++i) + if(translators[i]->translate(res)) + return res; + // clang-format off + try { + throw; + } catch(std::exception& ex) { + return ex.what(); + } catch(std::string& msg) { + return msg.c_str(); + } catch(const char* msg) { + return msg; + } catch(...) { + return "unknown exception"; } - return res.result; +// clang-format on #else // DOCTEST_CONFIG_NO_EXCEPTIONS return ""; #endif // DOCTEST_CONFIG_NO_EXCEPTIONS |