changeset 3007:c9f93628215a

more error details
author am@osimis.io
date Thu, 13 Dec 2018 14:48:23 +0100
parents 3ca27070df78
children 45a4a1571b4e
files Core/DicomFormat/DicomImageInformation.cpp
diffstat 1 files changed, 18 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomFormat/DicomImageInformation.cpp	Tue Dec 11 15:34:57 2018 +0100
+++ b/Core/DicomFormat/DicomImageInformation.cpp	Thu Dec 13 14:48:23 2018 +0100
@@ -20,7 +20,7 @@
  * you do not wish to do so, delete this exception statement from your
  * version. If you delete this exception statement from all source files
  * in the program, then also delete it here.
- * 
+ *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -195,17 +195,23 @@
       numberOfFrames_ = 1;
     }
 
-    if ((bitsAllocated_ != 8 && bitsAllocated_ != 16 && 
-         bitsAllocated_ != 24 && bitsAllocated_ != 32) ||
-        numberOfFrames_ == 0 ||
-        (planarConfiguration != 0 && planarConfiguration != 1))
+    if (bitsAllocated_ != 8 && bitsAllocated_ != 16 &&
+        bitsAllocated_ != 24 && bitsAllocated_ != 32)
     {
-      throw OrthancException(ErrorCode_NotImplemented);
+      throw OrthancException(ErrorCode_IncompatibleImageFormat, "Image not supported: " + boost::lexical_cast<std::string>(bitsAllocated_) + " bits allocated");
+    }
+    else if (numberOfFrames_ == 0)
+    {
+      throw OrthancException(ErrorCode_IncompatibleImageFormat, "Image not supported (no frames)");
+    }
+    else if (planarConfiguration != 0 && planarConfiguration != 1)
+    {
+      throw OrthancException(ErrorCode_IncompatibleImageFormat, "Image not supported: planar configuration is " + boost::lexical_cast<std::string>(planarConfiguration));
     }
 
     if (samplesPerPixel_ == 0)
     {
-      throw OrthancException(ErrorCode_NotImplemented);
+      throw OrthancException(ErrorCode_IncompatibleImageFormat, "Image not supported: samples per pixel is 0");
     }
 
     bytesPerValue_ = bitsAllocated_ / 8;
@@ -279,8 +285,8 @@
       }
     }
 
-    if (GetBitsStored() == 8 && 
-        GetChannelCount() == 3 && 
+    if (GetBitsStored() == 8 &&
+        GetChannelCount() == 3 &&
         !IsSigned() &&
         (ignorePhotometricInterpretation || photometric_ == PhotometricInterpretation_RGB))
     {
@@ -294,9 +300,9 @@
 
   size_t DicomImageInformation::GetFrameSize() const
   {
-    return (GetHeight() * 
-            GetWidth() * 
-            GetBytesPerValue() * 
+    return (GetHeight() *
+            GetWidth() *
+            GetBytesPerValue() *
             GetChannelCount());
   }
 }