Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/internal
diff options
context:
space:
mode:
authorMartin Hořeňovský2023-03-23 12:26:44 +0100
committerMartin Hořeňovský2023-03-23 12:26:44 +0100
commit3230760db2094019b2f34929095e8b4e9683e7f8 (patch)
tree25e9f2859791992eb26e2662ec7da03b9e0e0815 /src/catch2/internal
parentb3ebce715e9686f664e2756043a4c0e0e387a112 (diff)
downloadcatch3-3230760db2094019b2f34929095e8b4e9683e7f8.tar.gz
Cleanup in translating exceptions to messages
Diffstat (limited to 'src/catch2/internal')
-rw-r--r--src/catch2/internal/catch_exception_translator_registry.cpp29
-rw-r--r--src/catch2/internal/catch_exception_translator_registry.hpp1
2 files changed, 15 insertions, 15 deletions
diff --git a/src/catch2/internal/catch_exception_translator_registry.cpp b/src/catch2/internal/catch_exception_translator_registry.cpp
index 0645c6ce..0805d74c 100644
--- a/src/catch2/internal/catch_exception_translator_registry.cpp
+++ b/src/catch2/internal/catch_exception_translator_registry.cpp
@@ -13,6 +13,20 @@
namespace Catch {
+ namespace {
+ static std::string tryTranslators(
+ std::vector<
+ Detail::unique_ptr<IExceptionTranslator const>> const& translators ) {
+ if ( translators.empty() ) {
+ std::rethrow_exception( std::current_exception() );
+ } else {
+ return translators[0]->translate( translators.begin() + 1,
+ translators.end() );
+ }
+ }
+
+ }
+
ExceptionTranslatorRegistry::~ExceptionTranslatorRegistry() {
}
@@ -37,7 +51,7 @@ namespace Catch {
// 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(m_translators);
}
// To avoid having to handle TFE explicitly everywhere, we just
// rethrow it so that it goes back up the caller.
@@ -61,23 +75,10 @@ namespace Catch {
}
}
- std::string ExceptionTranslatorRegistry::tryTranslators() const {
- if (m_translators.empty()) {
- std::rethrow_exception(std::current_exception());
- } else {
- return m_translators[0]->translate(m_translators.begin() + 1, m_translators.end());
- }
- }
-
#else // ^^ Exceptions are enabled // Exceptions are disabled vv
std::string ExceptionTranslatorRegistry::translateActiveException() const {
CATCH_INTERNAL_ERROR("Attempted to translate active exception under CATCH_CONFIG_DISABLE_EXCEPTIONS!");
}
-
- std::string ExceptionTranslatorRegistry::tryTranslators() const {
- CATCH_INTERNAL_ERROR("Attempted to use exception translators under CATCH_CONFIG_DISABLE_EXCEPTIONS!");
- }
#endif
-
}
diff --git a/src/catch2/internal/catch_exception_translator_registry.hpp b/src/catch2/internal/catch_exception_translator_registry.hpp
index 2aafa684..3123e93d 100644
--- a/src/catch2/internal/catch_exception_translator_registry.hpp
+++ b/src/catch2/internal/catch_exception_translator_registry.hpp
@@ -21,7 +21,6 @@ namespace Catch {
~ExceptionTranslatorRegistry() override;
void registerTranslator( Detail::unique_ptr<IExceptionTranslator>&& translator );
std::string translateActiveException() const override;
- std::string tryTranslators() const;
private:
ExceptionTranslators m_translators;