changeset 504:50d9660f960c laaw

laaw exception
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 18 Jul 2013 10:12:20 +0200
parents ee33c7d0cda0
children 6e4bd06c17c5
files OrthancCppClient/Instance.cpp OrthancCppClient/Instance.h OrthancCppClient/OrthancClientException.h OrthancCppClient/OrthancConnection.cpp OrthancCppClient/Package/Test.sh OrthancCppClient/Patient.cpp OrthancCppClient/Series.cpp OrthancCppClient/Study.cpp
diffstat 8 files changed, 84 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancCppClient/Instance.cpp	Thu Jul 18 09:32:03 2013 +0200
+++ b/OrthancCppClient/Instance.cpp	Thu Jul 18 10:12:20 2013 +0200
@@ -33,7 +33,6 @@
 #include "Instance.h"
 
 #include "OrthancConnection.h"
-#include "../Core/OrthancException.h"
 
 #include <boost/lexical_cast.hpp>
 
@@ -63,7 +62,7 @@
           break;
           
         default:
-          throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
+          throw OrthancClientException(Orthanc::ErrorCode_NotImplemented);
       }
 
       Orthanc::HttpClient client(connection_.GetHttpClient());
@@ -72,7 +71,7 @@
 
       if (!client.Apply(png))
       {
-        throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
+        throw OrthancClientException(Orthanc::ErrorCode_NotImplemented);
       }
      
       reader_.reset(new Orthanc::PngReader);
@@ -92,7 +91,7 @@
     Json::Value v;
     if (!client.Apply(tags_))
     {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
+      throw OrthancClientException(Orthanc::ErrorCode_NetworkProtocol);
     }
   }
 
@@ -104,7 +103,7 @@
     }
     else
     {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_InexistentItem);
+      throw OrthancClientException(Orthanc::ErrorCode_InexistentItem);
     }
   }
 
@@ -118,7 +117,7 @@
     }
     catch (boost::bad_lexical_cast)
     {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
+      throw OrthancClientException(Orthanc::ErrorCode_BadFileFormat);
     }
   }
 
@@ -132,7 +131,7 @@
     }
     catch (boost::bad_lexical_cast)
     {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
+      throw OrthancClientException(Orthanc::ErrorCode_BadFileFormat);
     }
   }
 
@@ -218,7 +217,7 @@
     catch (boost::bad_lexical_cast)
     {
       // Unable to parse the Image Orientation Patient.
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
+      throw OrthancClientException(Orthanc::ErrorCode_BadFileFormat);
     }
   }
 }
--- a/OrthancCppClient/Instance.h	Thu Jul 18 09:32:03 2013 +0200
+++ b/OrthancCppClient/Instance.h	Thu Jul 18 10:12:20 2013 +0200
@@ -35,7 +35,7 @@
 #include <string>
 #include <json/value.h>
 
-#include "Package/Laaw/laaw.h"
+#include "OrthancClientException.h"
 #include "../Core/IDynamicObject.h"
 #include "../Core/FileFormats/PngReader.h"
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OrthancCppClient/OrthancClientException.h	Thu Jul 18 10:12:20 2013 +0200
@@ -0,0 +1,58 @@
+/**
+ * Orthanc - A Lightweight, RESTful DICOM Store
+ * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege,
+ * Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * In addition, as a special exception, the copyright holders of this
+ * program give permission to link the code of its release with the
+ * OpenSSL project's "OpenSSL" library (or with modified versions of it
+ * that use the same license as the "OpenSSL" library), and distribute
+ * the linked executables. You must obey the GNU General Public License
+ * in all respects for all of the code used other than "OpenSSL". If you
+ * modify file(s) with this exception, you may extend this exception to
+ * your version of the file(s), but you are not obligated to do so. If
+ * 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+
+#pragma once
+
+#include "../Core/OrthancException.h"
+#include "Package/Laaw/laaw.h"
+
+namespace OrthancClient
+{
+  class OrthancClientException : public ::Laaw::LaawException
+  {
+  public:
+    OrthancClientException(Orthanc::ErrorCode code) :
+      LaawException(Orthanc::OrthancException::GetDescription(code))
+    { 
+    }
+
+    OrthancClientException(const char* message) : 
+      LaawException(message)
+    {    
+    }
+
+    OrthancClientException(const std::string& message) : 
+      LaawException(message)
+    {    
+    }
+  };
+}
--- a/OrthancCppClient/OrthancConnection.cpp	Thu Jul 18 09:32:03 2013 +0200
+++ b/OrthancCppClient/OrthancConnection.cpp	Thu Jul 18 10:12:20 2013 +0200
@@ -32,8 +32,6 @@
 
 #include "OrthancConnection.h"
 
-#include "../Core/OrthancException.h"
-
 namespace OrthancClient
 {
   void OrthancConnection::ReadPatients()
@@ -42,7 +40,7 @@
     Json::Value v;
     if (!client_.Apply(content_))
     {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
+      throw OrthancClientException(Orthanc::ErrorCode_NetworkProtocol);
     }
   }
 
--- a/OrthancCppClient/Package/Test.sh	Thu Jul 18 09:32:03 2013 +0200
+++ b/OrthancCppClient/Package/Test.sh	Thu Jul 18 10:12:20 2013 +0200
@@ -3,6 +3,7 @@
 mkdir -p Build
 LAAW_ROOT=~/Subversion/Jomago/Src/Labo/Laaw
 
-${LAAW_ROOT}/Parser/Build/LaawParser.exe Build/CodeModelRaw.json ../OrthancConnection.h -I`pwd`/../../s/jsoncpp-src-0.6.0-rc2/include -fms-extensions && \
-    python ${LAAW_ROOT}/Generators/CodeModelPostProcessing.py Build/CodeModel.json Build/CodeModelRaw.json Product.json && \
-    python ${LAAW_ROOT}/Generators/GenerateWrapperCpp.py Build/OrthancClient.h Build/CodeModel.json Product.json ConfigurationCpp.json
+#${LAAW_ROOT}/Parser/Build/LaawParser.exe Build/CodeModelRaw.json ../OrthancConnection.h -I`pwd`/../../s/jsoncpp-src-0.6.0-rc2/include -fms-extensions && \
+#    python ${LAAW_ROOT}/Generators/CodeModelPostProcessing.py Build/CodeModel.json Build/CodeModelRaw.json Product.json && \
+    python ${LAAW_ROOT}/Generators/GenerateWrapperCpp.py Build/OrthancClient.h Build/CodeModel.json Product.json ConfigurationCpp.json && \
+    python ${LAAW_ROOT}/Generators/GenerateExternC.py Build/ExternC.cpp Build/CodeModel.json Product.json
--- a/OrthancCppClient/Patient.cpp	Thu Jul 18 09:32:03 2013 +0200
+++ b/OrthancCppClient/Patient.cpp	Thu Jul 18 10:12:20 2013 +0200
@@ -33,7 +33,6 @@
 #include "Patient.h"
 
 #include "OrthancConnection.h"
-#include "../Core/OrthancException.h"
 
 namespace OrthancClient
 {
@@ -45,7 +44,7 @@
     Json::Value v;
     if (!client.Apply(patient_))
     {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
+      throw OrthancClientException(Orthanc::ErrorCode_NetworkProtocol);
     }
   }
 
--- a/OrthancCppClient/Series.cpp	Thu Jul 18 09:32:03 2013 +0200
+++ b/OrthancCppClient/Series.cpp	Thu Jul 18 10:12:20 2013 +0200
@@ -33,7 +33,6 @@
 #include "Series.h"
 
 #include "OrthancConnection.h"
-#include "../Core/OrthancException.h"
 
 #include <set>
 #include <boost/lexical_cast.hpp>
@@ -61,7 +60,7 @@
 
         if (cosines.size() != 6)
         {
-          throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
+          throw OrthancClientException(Orthanc::ErrorCode_BadFileFormat);
         }
 
         normal_[0] = cosines[1] * cosines[5] - cosines[2] * cosines[4];
@@ -79,7 +78,7 @@
         instance.SplitVectorOfFloats(ipp, "ImagePositionPatient");
         if (ipp.size() != 3)
         {
-          throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
+          throw OrthancClientException(Orthanc::ErrorCode_BadFileFormat);
         }
 
         float dist = 0;
@@ -144,7 +143,7 @@
           }
           else
           {
-            throw OrthancException(ErrorCode_NotImplemented);
+            throw OrthancClientException(ErrorCode_NotImplemented);
           }
         }
 
@@ -161,7 +160,7 @@
   {
     if (!Is3DImage())
     {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
+      throw OrthancClientException(Orthanc::ErrorCode_NotImplemented);
     }
   }
 
@@ -199,7 +198,7 @@
 
       return l.size() == GetInstanceCount();
     }
-    catch (Orthanc::OrthancException)
+    catch (OrthancClientException)
     {
       return false;
     }
@@ -213,7 +212,7 @@
     Json::Value v;
     if (!client.Apply(series_))
     {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
+      throw OrthancClientException(Orthanc::ErrorCode_NetworkProtocol);
     }
   }
 
@@ -311,7 +310,7 @@
       }
       catch (boost::bad_lexical_cast)
       {
-        throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
+        throw OrthancClientException(Orthanc::ErrorCode_NotImplemented);
       }
     }
 
@@ -371,7 +370,7 @@
         break;
 
       default:
-        throw OrthancException(ErrorCode_NotImplemented);
+        throw OrthancClientException(ErrorCode_NotImplemented);
     }
 
 
@@ -382,7 +381,7 @@
     if (lineStride < sx * bytesPerPixel ||
         stackStride < sx * sy * bytesPerPixel)
     {
-      throw OrthancException(ErrorCode_BadRequest);
+      throw OrthancClientException(ErrorCode_BadRequest);
     }
 
     if (sx == 0 || sy == 0 || GetInstanceCount() == 0)
@@ -412,7 +411,7 @@
     if (instances.size() != GetInstanceCount())
     {
       // Several instances have the same Z coordinate
-      throw OrthancException(ErrorCode_NotImplemented);
+      throw OrthancClientException(ErrorCode_NotImplemented);
     }
 
 
@@ -435,7 +434,7 @@
     // Wait for all the stacks to be downloaded
     if (!processor.Join())
     {
-      throw OrthancException(ErrorCode_NetworkProtocol);
+      throw OrthancClientException(ErrorCode_NetworkProtocol);
     }
   }
 
--- a/OrthancCppClient/Study.cpp	Thu Jul 18 09:32:03 2013 +0200
+++ b/OrthancCppClient/Study.cpp	Thu Jul 18 10:12:20 2013 +0200
@@ -33,7 +33,6 @@
 #include "Study.h"
 
 #include "OrthancConnection.h"
-#include "../Core/OrthancException.h"
 
 namespace OrthancClient
 {
@@ -45,7 +44,7 @@
     Json::Value v;
     if (!client.Apply(study_))
     {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
+      throw OrthancClientException(Orthanc::ErrorCode_NetworkProtocol);
     }
   }