changeset 7108:247101bd4e74

replace exceptions by assert() in debug mode for logging
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 14 Aug 2026 08:37:38 +0200
parents 73775b15af9c
children 823a4e5e9fc4
files OrthancFramework/Sources/Logging.cpp
diffstat 1 files changed, 7 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/Logging.cpp	Fri Aug 14 08:05:15 2026 +0200
+++ b/OrthancFramework/Sources/Logging.cpp	Fri Aug 14 08:37:38 2026 +0200
@@ -662,10 +662,9 @@
 #if !defined(NDEBUG)
       if (hasName_)
       {
-        throw Orthanc::OrthancException(
-          Orthanc::ErrorCode_InternalError, "This thread already has a name or another thread is re-using "
-          "the same threadId and you have not called 'ClearCurrentThreadName()': " + name,
-          false /* don't log to avoid deadlock */);
+        std::cerr << "This thread already has a name or another thread is re-using "
+                  << "the same threadId and you have not called \"ClearCurrentThreadName()\": " << name << std::endl;
+        assert(0);
       }
 #endif
 
@@ -703,8 +702,8 @@
       if (context_.empty())
       {
 #if !defined(NDEBUG)
-        throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "Cannot pop from an empty context",
-                                        false /* don't log to avoid deadlock */);
+        std::cerr << "Cannot pop from an empty context" << std::endl;
+        assert(0);
 #endif
       }
       else
@@ -892,9 +891,8 @@
               it->second->HasThreadName() &&
               it->second->GetThreadName() == formattedName)
           {
-            throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,
-                                            "Another thread already uses this thread name: " + name,
-                                            false /* don't log to avoid deadlock */);
+            std::cerr << "Another thread already uses this thread name: " << name << std::endl;
+            assert(0);
           }
         }
 #endif