diff Core/Images/ImageAccessor.cpp @ 2954:d924f9bb61cc

taking advantage of details in OrthancException
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 03 Dec 2018 14:35:34 +0100
parents 0f07bdae0805
children 4e43e67f8ecf
line wrap: on
line diff
--- a/Core/Images/ImageAccessor.cpp	Mon Dec 03 11:49:39 2018 +0100
+++ b/Core/Images/ImageAccessor.cpp	Mon Dec 03 14:35:34 2018 +0100
@@ -107,11 +107,8 @@
   {
     if (readOnly_)
     {
-#if ORTHANC_ENABLE_LOGGING == 1
-      LOG(ERROR) << "Trying to write on a read-only image";
-#endif
-
-      throw OrthancException(ErrorCode_ReadOnly);
+      throw OrthancException(ErrorCode_ReadOnly,
+                             "Trying to write to a read-only image");
     }
 
     return buffer_;
@@ -135,11 +132,8 @@
   {
     if (readOnly_)
     {
-#if ORTHANC_ENABLE_LOGGING == 1
-      LOG(ERROR) << "Trying to write on a read-only image";
-#endif
-
-      throw OrthancException(ErrorCode_ReadOnly);
+      throw OrthancException(ErrorCode_ReadOnly,
+                             "Trying to write to a read-only image");
     }
 
     if (buffer_ != NULL)
@@ -299,10 +293,8 @@
   {
     if (readOnly_)
     {
-#if ORTHANC_ENABLE_LOGGING == 1
-      LOG(ERROR) << "Trying to modify the format of a read-only image";
-#endif
-      throw OrthancException(ErrorCode_ReadOnly);
+      throw OrthancException(ErrorCode_ReadOnly,
+                             "Trying to modify the format of a read-only image");
     }
 
     if (::Orthanc::GetBytesPerPixel(format) != ::Orthanc::GetBytesPerPixel(format_))