diff OrthancCppClient/HttpClient.cpp @ 475:72cca077abf8

removal of HttpException
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 15 Jul 2013 17:32:47 +0200
parents c9a5d72f8481
children
line wrap: on
line diff
--- a/OrthancCppClient/HttpClient.cpp	Mon Jul 15 17:25:53 2013 +0200
+++ b/OrthancCppClient/HttpClient.cpp	Mon Jul 15 17:32:47 2013 +0200
@@ -27,6 +27,9 @@
 
 #include "HttpClient.h"
 
+#include "../Core/Toolbox.h"
+#include "../Core/OrthancException.h"
+
 #include <string.h>
 #include <curl/curl.h>
 
@@ -44,8 +47,7 @@
   {
     if (code != CURLE_OK)
     {
-      //printf("ICI: %s\n", curl_easy_strerror(code));
-      throw HttpException("CURL: " + std::string(curl_easy_strerror(code)));
+      throw OrthancException("libCURL error: " + std::string(curl_easy_strerror(code)));
     }
 
     return code;
@@ -74,14 +76,14 @@
     pimpl_->postHeaders_ = NULL;
     if ((pimpl_->postHeaders_ = curl_slist_append(pimpl_->postHeaders_, "Expect:")) == NULL)
     {
-      throw HttpException("HttpClient: Not enough memory");
+      throw OrthancException(ErrorCode_NotEnoughMemory);
     }
 
     pimpl_->curl_ = curl_easy_init();
     if (!pimpl_->curl_)
     {
       curl_slist_free_all(pimpl_->postHeaders_);
-      throw HttpException("HttpClient: Not enough memory");
+      throw OrthancException(ErrorCode_NotEnoughMemory);
     }
 
     CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_WRITEFUNCTION, &CurlCallback));
@@ -193,7 +195,7 @@
       break;
 
     default:
-      throw HttpException("HttpClient: Internal error");
+      throw OrthancException(ErrorCode_InternalError);
     }
 
     // Do the actual request
@@ -247,4 +249,9 @@
   {
     curl_global_cleanup();
   }
+
+  const char* HttpClient::GetLastStatusText() const
+  {
+    return Toolbox::ToString(lastStatus_);
+  }
 }