arpadboda commented on a change in pull request #710: MINIFICPP - 1110,1111 - 
PublishKafka, OPC processors should config and
URL: https://github.com/apache/nifi-minifi-cpp/pull/710#discussion_r369626667
 
 

 ##########
 File path: extensions/librdkafka/PublishKafka.cpp
 ##########
 @@ -187,81 +239,77 @@ bool PublishKafka::configureNewConnection(const 
std::shared_ptr<KafkaConnection>
   auto key = conn->getKey();
 
   if (key->brokers_.empty()) {
-    logger_->log_error("There are no brokers");
-    return false;
+    throw Exception(PROCESS_SCHEDULE_EXCEPTION, "There are no brokers");
   }
   result = rd_kafka_conf_set(conf_, "bootstrap.servers", 
key->brokers_.c_str(), errstr.data(), errstr.size());
   logger_->log_debug("PublishKafka: bootstrap.servers [%s]", key->brokers_);
   if (result != RD_KAFKA_CONF_OK) {
-    logger_->log_error("PublishKafka: configure error result [%s]", 
errstr.data());
-    return false;
+    auto error_msg = utils::StringUtils::join_pack("PublishKafka: configure 
error result [%s]", errstr.data());
+    throw Exception(PROCESS_SCHEDULE_EXCEPTION, error_msg);
   }
 
   if (key->client_id_.empty()) {
-    logger_->log_error("Client id is empty");
-    return false;
+    throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Client id is empty");
   }
   result = rd_kafka_conf_set(conf_, "client.id", key->client_id_.c_str(), 
errstr.data(), errstr.size());
   logger_->log_debug("PublishKafka: client.id [%s]", key->client_id_);
   if (result != RD_KAFKA_CONF_OK) {
-    logger_->log_error("PublishKafka: configure error result [%s]", 
errstr.data());
-    return false;
+    auto error_msg = utils::StringUtils::join_pack("PublishKafka: configure 
error result ", errstr.data());
 
 Review comment:
   Nitpicking: a ':' would be nice to indicate where the error string begins
   
   The same applies for all these cases.
   
   Altough it's used in many places, so I think it would be better to prepar 
the error string and just concat the actual error when throwing the exception 
to avoid multiplication of this code snippet.  

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to