You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ph...@apache.org on 2018/12/05 19:50:47 UTC

nifi-minifi-cpp git commit: MINIFICPP-689 - Make minifi::Exception constructible with string param

Repository: nifi-minifi-cpp
Updated Branches:
  refs/heads/master 05ee9d339 -> 3d637743f


MINIFICPP-689 - Make minifi::Exception constructible with string param

This closes #455.

Signed-off-by: Marc Parisi <ph...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/commit/3d637743
Tree: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/tree/3d637743
Diff: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/diff/3d637743

Branch: refs/heads/master
Commit: 3d637743f74c11ed820674079bbbd9a3dd95b670
Parents: 05ee9d3
Author: Arpad Boda <ab...@hortonworks.com>
Authored: Wed Dec 5 12:45:42 2018 +0100
Committer: Marc Parisi <ph...@apache.org>
Committed: Wed Dec 5 14:50:31 2018 -0500

----------------------------------------------------------------------
 extensions/http-curl/sitetosite/HTTPProtocol.cpp |  2 +-
 extensions/http-curl/sitetosite/PeersEntity.h    |  3 +--
 extensions/libarchive/ArchiveMetadata.cpp        |  3 +--
 libminifi/include/Exception.h                    | 11 ++++++-----
 libminifi/src/core/ProcessSession.cpp            |  4 ++--
 libminifi/src/sitetosite/SiteToSiteClient.cpp    | 12 ++++--------
 6 files changed, 15 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/3d637743/extensions/http-curl/sitetosite/HTTPProtocol.cpp
----------------------------------------------------------------------
diff --git a/extensions/http-curl/sitetosite/HTTPProtocol.cpp b/extensions/http-curl/sitetosite/HTTPProtocol.cpp
index 7698f50..0c1d0f9 100644
--- a/extensions/http-curl/sitetosite/HTTPProtocol.cpp
+++ b/extensions/http-curl/sitetosite/HTTPProtocol.cpp
@@ -289,7 +289,7 @@ void HttpSiteToSiteClient::closeTransaction(const std::string &transactionID) {
   if (client->getResponseCode() == 400) {
     std::stringstream message;
     message << "Received " << client->getResponseCode() << " from " << uri.str();
-    throw Exception(SITE2SITE_EXCEPTION, message.str().c_str());
+    throw Exception(SITE2SITE_EXCEPTION, message.str());
   }
 
   transaction->closed_ = true;

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/3d637743/extensions/http-curl/sitetosite/PeersEntity.h
----------------------------------------------------------------------
diff --git a/extensions/http-curl/sitetosite/PeersEntity.h b/extensions/http-curl/sitetosite/PeersEntity.h
index 93496b3..a43df8c 100644
--- a/extensions/http-curl/sitetosite/PeersEntity.h
+++ b/extensions/http-curl/sitetosite/PeersEntity.h
@@ -50,9 +50,8 @@ class PeersEntity {
           ss << "Failed to parse archive lens stack from JSON string with reason: "
              << rapidjson::GetParseError_En(ok.Code())
              << " at offset " << ok.Offset();
-          std::string exception_msg = ss.str();
   
-          throw Exception(ExceptionType::GENERAL_EXCEPTION, exception_msg.c_str());
+          throw Exception(ExceptionType::GENERAL_EXCEPTION, ss.str());
       }
 
       if (root.HasMember("peers") && root["peers"].IsArray() && root["peers"].Size() > 0) {

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/3d637743/extensions/libarchive/ArchiveMetadata.cpp
----------------------------------------------------------------------
diff --git a/extensions/libarchive/ArchiveMetadata.cpp b/extensions/libarchive/ArchiveMetadata.cpp
index 0544b22..83e7aa5 100644
--- a/extensions/libarchive/ArchiveMetadata.cpp
+++ b/extensions/libarchive/ArchiveMetadata.cpp
@@ -179,9 +179,8 @@ void ArchiveStack::loadJsonString(const std::string& input) {
         ss << "Failed to parse archive lens stack from JSON string with reason: "
            << rapidjson::GetParseError_En(ok.Code())
            << " at offset " << ok.Offset();
-        std::string exception_msg = ss.str();
 
-        throw Exception(ExceptionType::GENERAL_EXCEPTION, exception_msg.c_str());
+        throw Exception(ExceptionType::GENERAL_EXCEPTION, ss.str());
     }
 
     loadJson(lensStack);

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/3d637743/libminifi/include/Exception.h
----------------------------------------------------------------------
diff --git a/libminifi/include/Exception.h b/libminifi/include/Exception.h
index 080d1bf..b539c39 100644
--- a/libminifi/include/Exception.h
+++ b/libminifi/include/Exception.h
@@ -60,16 +60,17 @@ class Exception : public std::exception {
  public:
   // Constructor
   /*!
-   * Create a new flow record
+   * Create a new exception
    */
-  Exception(ExceptionType type, const char *errorMsg)
+  Exception(ExceptionType type, std::string errorMsg)
       : _type(type),
-        _errorMsg(errorMsg) {
+        _errorMsg(std::move(errorMsg)) {
   }
+
   // Destructor
-  virtual ~Exception() throw () {
+  virtual ~Exception() noexcept {
   }
-  virtual const char * what() const throw () {
+  virtual const char * what() const noexcept {
 
     _whatStr = ExceptionTypeToString(_type);
 

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/3d637743/libminifi/src/core/ProcessSession.cpp
----------------------------------------------------------------------
diff --git a/libminifi/src/core/ProcessSession.cpp b/libminifi/src/core/ProcessSession.cpp
index 6981bce..ab7e4bf 100644
--- a/libminifi/src/core/ProcessSession.cpp
+++ b/libminifi/src/core/ProcessSession.cpp
@@ -704,7 +704,7 @@ void ProcessSession::commit() {
           if (!process_context_->getProcessorNode()->isAutoTerminated(relationship)) {
             // Not autoterminate, we should have the connect
             std::string message = "Connect empty for non auto terminated relationship " + relationship.getName();
-            throw Exception(PROCESS_SESSION_EXCEPTION, message.c_str());
+            throw Exception(PROCESS_SESSION_EXCEPTION, message);
           } else {
             // Autoterminated
             remove(record);
@@ -748,7 +748,7 @@ void ProcessSession::commit() {
           if (!process_context_->getProcessorNode()->isAutoTerminated(relationship)) {
             // Not autoterminate, we should have the connect
             std::string message = "Connect empty for non auto terminated relationship " + relationship.getName();
-            throw Exception(PROCESS_SESSION_EXCEPTION, message.c_str());
+            throw Exception(PROCESS_SESSION_EXCEPTION, message);
           } else {
             logger_->log_debug("added flow file is auto terminated");
             // Auto-terminated

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/3d637743/libminifi/src/sitetosite/SiteToSiteClient.cpp
----------------------------------------------------------------------
diff --git a/libminifi/src/sitetosite/SiteToSiteClient.cpp b/libminifi/src/sitetosite/SiteToSiteClient.cpp
index 142de56..61fefdf 100644
--- a/libminifi/src/sitetosite/SiteToSiteClient.cpp
+++ b/libminifi/src/sitetosite/SiteToSiteClient.cpp
@@ -209,14 +209,10 @@ bool SiteToSiteClient::transferFlowFiles(const std::shared_ptr<core::ProcessCont
     }  // while true
 
     if (!confirm(transactionID)) {
-      std::stringstream ss;
-      ss << "Confirm Failed for " << transactionID;
-      throw Exception(SITE2SITE_EXCEPTION, ss.str().c_str());
+      throw Exception(SITE2SITE_EXCEPTION, "Confirm Failed for " + transactionID);
     }
     if (!complete(transactionID)) {
-      std::stringstream ss;
-      ss << "Complete Failed for " << transactionID;
-      throw Exception(SITE2SITE_EXCEPTION, ss.str().c_str());
+      throw Exception(SITE2SITE_EXCEPTION, "Complete Failed for " + transactionID);
     }
     logger_->log_debug("Site2Site transaction %s successfully send flow record %d, content bytes %llu", transactionID, transaction->total_transfers_, transaction->_bytes);
   } catch (std::exception &exception) {
@@ -727,7 +723,7 @@ bool SiteToSiteClient::receiveFlowFiles(const std::shared_ptr<core::ProcessConte
         if (flowFile->getSize() != packet._size) {
           std::stringstream message;
           message << "Receive size not correct, expected to send " << flowFile->getSize() << " bytes, but actually sent " << packet._size;
-          throw Exception(SITE2SITE_EXCEPTION, message.str().c_str());
+          throw Exception(SITE2SITE_EXCEPTION, message.str());
         } else {
           logger_->log_debug("received %llu with expected %llu", flowFile->getSize(), packet._size);
         }
@@ -749,7 +745,7 @@ bool SiteToSiteClient::receiveFlowFiles(const std::shared_ptr<core::ProcessConte
     if (!complete(transactionID)) {
       std::stringstream transaction_str;
       transaction_str << "Complete Transaction " << transactionID << " Failed";
-      throw Exception(SITE2SITE_EXCEPTION, transaction_str.str().c_str());
+      throw Exception(SITE2SITE_EXCEPTION, transaction_str.str());
     }
     logging::LOG_INFO(logger_) << "Site to Site transaction " << transactionID << " received flow record " << transfers
                                << ", with content size " << bytes << " bytes";