changeset 1870:a6c431193c79

Improved logging information if upgrade fails
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 05 Dec 2015 12:45:19 +0100
parents 9af3b492b010
children 09a737a6bf36
files NEWS OrthancServer/ServerToolbox.cpp
diffstat 2 files changed, 24 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Sat Dec 05 11:22:17 2015 +0100
+++ b/NEWS	Sat Dec 05 12:45:19 2015 +0100
@@ -3,6 +3,7 @@
 
 * Fix modality worklists server if some fields are null
 * More tolerant "/series/.../ordered-slices" with broken series
+* Improved logging information if upgrade fails
 
 
 Version 0.9.5 (2015/12/02)
--- a/OrthancServer/ServerToolbox.cpp	Sat Dec 05 11:22:17 2015 +0100
+++ b/OrthancServer/ServerToolbox.cpp	Sat Dec 05 12:45:19 2015 +0100
@@ -322,6 +322,8 @@
             tmp != level ||
             !FindOneChildInstance(instance, database, resource, level))
         {
+          LOG(ERROR) << "Cannot find an instance for " << EnumerationToString(level) 
+                     << " with identifier " << *it;
           throw OrthancException(ErrorCode_InternalError);
         }
 
@@ -329,23 +331,33 @@
         FileInfo attachment;
         if (!database.LookupAttachment(attachment, instance, FileContentType_Dicom))
         {
+          LOG(ERROR) << "Cannot retrieve the DICOM file associated with instance " << database.GetPublicId(instance);
           throw OrthancException(ErrorCode_InternalError);
         }
 
-        // Read and parse the content of the DICOM file
-        StorageAccessor accessor(storageArea);
+        try
+        {
+          // Read and parse the content of the DICOM file
+          StorageAccessor accessor(storageArea);
 
-        std::string content;
-        accessor.Read(content, attachment);
+          std::string content;
+          accessor.Read(content, attachment);
+
+          ParsedDicomFile dicom(content);
 
-        ParsedDicomFile dicom(content);
+          // Update the tags of this resource
+          DicomMap dicomSummary;
+          dicom.Convert(dicomSummary);
 
-        // Update the tags of this resource
-        DicomMap dicomSummary;
-        dicom.Convert(dicomSummary);
-
-        database.ClearMainDicomTags(resource);
-        Toolbox::SetMainDicomTags(database, resource, level, dicomSummary);
+          database.ClearMainDicomTags(resource);
+          Toolbox::SetMainDicomTags(database, resource, level, dicomSummary);
+        }
+        catch (OrthancException&)
+        {
+          LOG(ERROR) << "Cannot decode the DICOM file with UUID " << attachment.GetUuid()
+                     << " associated with instance " << database.GetPublicId(instance);
+          throw;
+        }
       }
     }
   }