Mercurial > hg > orthanc-databases
diff Framework/Common/ImplicitTransaction.cpp @ 28:c0cb5d2cd696
checks depending on Orthanc version
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 16 Jul 2018 14:48:43 +0200 |
parents | 69a94267cdea |
children | 714c5d2bee76 |
line wrap: on
line diff
--- a/Framework/Common/ImplicitTransaction.cpp Sat Jul 14 13:18:31 2018 +0200 +++ b/Framework/Common/ImplicitTransaction.cpp Mon Jul 16 14:48:43 2018 +0200 @@ -28,6 +28,9 @@ namespace OrthancDatabases { + static bool isErrorOnDoubleExecution_ = false; + + ImplicitTransaction::ImplicitTransaction() : state_(State_Ready), readOnly_(true) @@ -92,22 +95,21 @@ break; case State_Executed: -#if defined(NDEBUG) - // Release build. Ignore such errors. - LOG(INFO) << "Cannot execute more than one statement in an implicit transaction"; + if (isErrorOnDoubleExecution_) + { + /** + * This allows to detect errors wrt. the handling of + * transactions in the Orthanc core. + * + * In Orthanc <= 1.3.2: problems in "/changes" (a transaction + * was missing because of GetPublicId()). + **/ + LOG(ERROR) << "Cannot execute more than one statement in an implicit transaction"; + throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); + } + break; -#else - /** - * Debug build. This allows to detect errors wrt. the handling - * of transactions in the Orthanc core. - * - * In Orthanc <= 1.3.2: problems in "/changes" (a transaction - * was missing because of GetPublicId()). - **/ - LOG(ERROR) << "Cannot execute more than one statement in an implicit transaction"; - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); -#endif - + case State_Committed: LOG(ERROR) << "Cannot commit twice an implicit transaction"; throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); @@ -147,5 +149,17 @@ state_ = State_Executed; } + + + void ImplicitTransaction::SetErrorOnDoubleExecution(bool isError) + { + isErrorOnDoubleExecution_ = isError; + } + + + bool ImplicitTransaction::IsErrorOnDoubleExecution() + { + return isErrorOnDoubleExecution_; + } }