diff Framework/Common/DatabaseManager.cpp @ 254:8a4ce70f456a

fix crash if connection to server is lost
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 14 Apr 2021 15:33:57 +0200
parents b97a537f4613
children d663d9e44f8d
line wrap: on
line diff
--- a/Framework/Common/DatabaseManager.cpp	Wed Apr 14 15:08:51 2021 +0200
+++ b/Framework/Common/DatabaseManager.cpp	Wed Apr 14 15:33:57 2021 +0200
@@ -171,6 +171,19 @@
   }
 
   
+  IDatabase& DatabaseManager::GetDatabase()
+  {
+    if (database_.get() == NULL)
+    {
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_DatabaseUnavailable);
+    }
+    else
+    {
+      return *database_;
+    }
+  }
+
+
   void DatabaseManager::StartTransaction(TransactionType type)
   {
     try