changeset 2135:cadfe0a2a393

fix in the sample basic plugin
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 09 Nov 2016 13:42:33 +0100
parents ddc75c6c712d
children dd609a99d39a
files OrthancServer/ServerContext.cpp Plugins/Engine/OrthancPlugins.cpp Plugins/Samples/Basic/Plugin.c
diffstat 3 files changed, 29 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/ServerContext.cpp	Wed Nov 09 12:04:09 2016 +0100
+++ b/OrthancServer/ServerContext.cpp	Wed Nov 09 13:42:33 2016 +0100
@@ -102,7 +102,8 @@
           catch (OrthancException& e)
           {
             LOG(ERROR) << "Error in the " << it->GetDescription() 
-                       << " callback while signaling a change: " << e.What();
+                       << " callback while signaling a change: " << e.What()
+                       << " (code " << e.GetErrorCode() << ")";
           }
         }
       }
@@ -222,7 +223,8 @@
           catch (OrthancException& e)
           {
             LOG(ERROR) << "Error in the " << it->GetDescription() 
-                       << " callback while receiving an instance: " << e.What();
+                       << " callback while receiving an instance: " << e.What()
+                       << " (code " << e.GetErrorCode() << ")";
             throw;
           }
         }
@@ -299,7 +301,8 @@
           catch (OrthancException& e)
           {
             LOG(ERROR) << "Error in the " << it->GetDescription() 
-                       << " callback while receiving an instance: " << e.What();
+                       << " callback while receiving an instance: " << e.What()
+                       << " (code " << e.GetErrorCode() << ")";
           }
         }
       }
--- a/Plugins/Engine/OrthancPlugins.cpp	Wed Nov 09 12:04:09 2016 +0100
+++ b/Plugins/Engine/OrthancPlugins.cpp	Wed Nov 09 13:42:33 2016 +0100
@@ -940,7 +940,7 @@
     }
     else
     {
-      GetErrorDictionary().LogError(error, true);
+      GetErrorDictionary().LogError(error, false);
       throw OrthancException(static_cast<ErrorCode>(error));
     }
   }
--- a/Plugins/Samples/Basic/Plugin.c	Wed Nov 09 12:04:09 2016 +0100
+++ b/Plugins/Samples/Basic/Plugin.c	Wed Nov 09 13:42:33 2016 +0100
@@ -28,9 +28,9 @@
 static OrthancPluginErrorCode customError;
 
 
-ORTHANC_PLUGINS_API int32_t Callback1(OrthancPluginRestOutput* output,
-                                      const char* url,
-                                      const OrthancPluginHttpRequest* request)
+ORTHANC_PLUGINS_API OrthancPluginErrorCode Callback1(OrthancPluginRestOutput* output,
+                                                     const char* url,
+                                                     const OrthancPluginHttpRequest* request)
 {
   char buffer[1024];
   uint32_t i;
@@ -57,7 +57,7 @@
     OrthancPluginLogWarning(context, buffer);    
   }
 
-  OrthancPluginLogWarning(context, "");    
+  OrthancPluginLogWarning(context, "");
 
   for (i = 0; i < request->headersCount; i++)
   {
@@ -67,13 +67,13 @@
 
   OrthancPluginLogWarning(context, "");
 
-  return 1;
+  return OrthancPluginErrorCode_Success;
 }
 
 
-ORTHANC_PLUGINS_API int32_t Callback2(OrthancPluginRestOutput* output,
-                                      const char* url,
-                                      const OrthancPluginHttpRequest* request)
+ORTHANC_PLUGINS_API OrthancPluginErrorCode Callback2(OrthancPluginRestOutput* output,
+                                                     const char* url,
+                                                     const OrthancPluginHttpRequest* request)
 {
   /* Answer with a sample 16bpp image. */
 
@@ -99,13 +99,13 @@
                                            256, 256, sizeof(uint16_t) * 256, buffer);
   }
 
-  return 0;
+  return OrthancPluginErrorCode_Success;
 }
 
 
-ORTHANC_PLUGINS_API int32_t Callback3(OrthancPluginRestOutput* output,
-                                      const char* url,
-                                      const OrthancPluginHttpRequest* request)
+ORTHANC_PLUGINS_API OrthancPluginErrorCode Callback3(OrthancPluginRestOutput* output,
+                                                     const char* url,
+                                                     const OrthancPluginHttpRequest* request)
 {
   if (request->method != OrthancPluginHttpMethod_Get)
   {
@@ -124,13 +124,13 @@
     }
   }
 
-  return 0;
+  return OrthancPluginErrorCode_Success;
 }
 
 
-ORTHANC_PLUGINS_API int32_t Callback4(OrthancPluginRestOutput* output,
-                                      const char* url,
-                                      const OrthancPluginHttpRequest* request)
+ORTHANC_PLUGINS_API OrthancPluginErrorCode Callback4(OrthancPluginRestOutput* output,
+                                                     const char* url,
+                                                     const OrthancPluginHttpRequest* request)
 {
   /* Answer with a sample 8bpp image. */
 
@@ -156,13 +156,13 @@
                                            256, 256, 256, buffer);
   }
 
-  return 0;
+  return OrthancPluginErrorCode_Success;
 }
 
 
-ORTHANC_PLUGINS_API int32_t Callback5(OrthancPluginRestOutput* output,
-                                      const char* url,
-                                      const OrthancPluginHttpRequest* request)
+ORTHANC_PLUGINS_API OrthancPluginErrorCode Callback5(OrthancPluginRestOutput* output,
+                                                     const char* url,
+                                                     const OrthancPluginHttpRequest* request)
 {
   /**
    * Demonstration the difference between the
@@ -199,13 +199,13 @@
 
   if (error)
   {
-    return -1;
+    return OrthancPluginErrorCode_InternalError;
   }
   else
   {
     OrthancPluginAnswerBuffer(context, output, tmp.data, tmp.size, "application/octet-stream");
     OrthancPluginFreeMemoryBuffer(context, &tmp);
-    return 0;
+    return OrthancPluginErrorCode_Success;
   }
 }