Fix connection error handling in Elasticsearch and InfluxDB features

Previously this would just throw the entire exception stack trace
which is not needed here.

fixes #6394
This commit is contained in:
Michael Friedrich 2018-06-21 15:41:40 +02:00
parent d2a6b260bb
commit 9ea0650edc
2 changed files with 22 additions and 2 deletions

View File

@ -428,7 +428,19 @@ void ElasticsearchWriter::SendRequest(const String& body)
url->SetPath(path);
Stream::Ptr stream = Connect();
Stream::Ptr stream;
try {
stream = Connect();
} catch (const std::exception& ex) {
Log(LogWarning, "ElasticsearchWriter")
<< "Flush failed, cannot connect to Elasticsearch.";
return;
}
if (!stream)
return;
HttpRequest req(stream);
/* Specify required headers by Elasticsearch. */

View File

@ -419,7 +419,15 @@ void InfluxdbWriter::Flush()
String body = boost::algorithm::join(m_DataBuffer, "\n");
m_DataBuffer.clear();
Stream::Ptr stream = Connect();
Stream::Ptr stream;
try {
stream = Connect();
} catch (const std::exception& ex) {
Log(LogWarning, "InfluxDbWriter")
<< "Flush failed, cannot connect to InfluxDB.";
return;
}
if (!stream)
return;