Previously this would just throw the entire exception stack trace
which is not needed here.
fixes #6394
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. */
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;