diff OrthancServer/Sources/ServerIndex.cpp @ 4614:67d112ef680f db-changes

added missing try/catch
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 12 Apr 2021 17:04:58 +0200
parents d494b4f1103e
children f7d5372b59b3
line wrap: on
line diff
--- a/OrthancServer/Sources/ServerIndex.cpp	Thu Apr 08 10:46:12 2021 +0200
+++ b/OrthancServer/Sources/ServerIndex.cpp	Mon Apr 12 17:04:58 2021 +0200
@@ -465,30 +465,37 @@
           }
         }
 
-        /**
-         * WARNING: Don't protect the calls to "LogChange()" using
-         * "monitoringMutex_", as this could lead to deadlocks in
-         * other threads (typically, if "Store()" is being running in
-         * another thread, which leads to calls to "MarkAsUnstable()",
-         * which leads to two lockings of "monitoringMutex_").
-         **/
-        switch (stableResource.GetResourceType())
+        try
         {
-          case ResourceType_Patient:
-            that->LogChange(stableId, ChangeType_StablePatient, stableResource.GetPublicId(), ResourceType_Patient);
-            break;
-            
-          case ResourceType_Study:
-            that->LogChange(stableId, ChangeType_StableStudy, stableResource.GetPublicId(), ResourceType_Study);
-            break;
+          /**
+           * WARNING: Don't protect the calls to "LogChange()" using
+           * "monitoringMutex_", as this could lead to deadlocks in
+           * other threads (typically, if "Store()" is being running in
+           * another thread, which leads to calls to "MarkAsUnstable()",
+           * which leads to two lockings of "monitoringMutex_").
+           **/
+          switch (stableResource.GetResourceType())
+          {
+            case ResourceType_Patient:
+              that->LogChange(stableId, ChangeType_StablePatient, stableResource.GetPublicId(), ResourceType_Patient);
+              break;
             
-          case ResourceType_Series:
-            that->LogChange(stableId, ChangeType_StableSeries, stableResource.GetPublicId(), ResourceType_Series);
-            break;
+            case ResourceType_Study:
+              that->LogChange(stableId, ChangeType_StableStudy, stableResource.GetPublicId(), ResourceType_Study);
+              break;
+            
+            case ResourceType_Series:
+              that->LogChange(stableId, ChangeType_StableSeries, stableResource.GetPublicId(), ResourceType_Series);
+              break;
             
-          default:
-            throw OrthancException(ErrorCode_InternalError);
+            default:
+              throw OrthancException(ErrorCode_InternalError);
+          }
         }
+        catch (OrthancException& e)
+        {
+          LOG(ERROR) << "Cannot log a change about a stable resource into the database";
+        }          
       }
     }