#include "CurlHandle.h"

#include <curl/curl.h>
#include <stdexcept>

namespace embeddedmz {

CurlHandle::CurlHandle() {
  const auto eCode = curl_global_init(CURL_GLOBAL_ALL);
  if (eCode != CURLE_OK) {
    throw std::runtime_error{"Error initializing libCURL"};
  }
}

CurlHandle::~CurlHandle() { curl_global_cleanup(); }

CurlHandle &CurlHandle::instance() {
  static CurlHandle inst{};
  return inst;
}

} // namespace embeddedmz

#include "CurlHandle.h"

#include <curl/curl.h>

namespace embeddedmz {

CurlHandle::CurlHandle() { curl_global_init(CURL_GLOBAL_ALL); }

CurlHandle::~CurlHandle() { curl_global_cleanup(); }

CurlHandle &CurlHandle::instance() {
  static CurlHandle inst{};
  return inst;
}

} // namespace embeddedmz

--- 
+++ 
@@ -1,10 +1,16 @@
 #include "CurlHandle.h"
 
 #include <curl/curl.h>
+#include <stdexcept>
 
 namespace embeddedmz {
 
-CurlHandle::CurlHandle() { curl_global_init(CURL_GLOBAL_ALL); }
+CurlHandle::CurlHandle() {
+  const auto eCode = curl_global_init(CURL_GLOBAL_ALL);
+  if (eCode != CURLE_OK) {
+    throw std::runtime_error{"Error initializing libCURL"};
+  }
+}
 
 CurlHandle::~CurlHandle() { curl_global_cleanup(); }
 
Check error code on curl_init
