Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/base/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ String icinga::DiagnosticInformation(const std::exception& ex, bool verbose, boo
return result.str();
}

String icinga::DiagnosticInformation(const boost::exception_ptr& eptr, bool verbose)
String icinga::DiagnosticInformation(const std::exception_ptr& eptr, bool verbose)
{
boost::stacktrace::stacktrace *pt = GetLastExceptionStack();
boost::stacktrace::stacktrace stack;
Expand All @@ -295,12 +295,12 @@ String icinga::DiagnosticInformation(const boost::exception_ptr& eptr, bool verb
context = *pc;

try {
boost::rethrow_exception(eptr);
std::rethrow_exception(eptr);
} catch (const std::exception& ex) {
return DiagnosticInformation(ex, verbose, pt ? &stack : nullptr, pc ? &context : nullptr);
} catch (...) {
return boost::current_exception_diagnostic_information();
}

return boost::diagnostic_information(eptr);
}

ScriptError::ScriptError(String message)
Expand Down
3 changes: 1 addition & 2 deletions lib/base/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <boost/exception/errinfo_errno.hpp>
#include <boost/exception/errinfo_file_name.hpp>
#include <boost/exception/diagnostic_information.hpp>
#include <boost/exception_ptr.hpp>
#include <boost/stacktrace.hpp>

#ifdef _WIN32
Expand Down Expand Up @@ -115,7 +114,7 @@ std::string to_string(const ContextTraceErrorInfo& e);
*/
String DiagnosticInformation(const std::exception& ex, bool verbose = true,
boost::stacktrace::stacktrace *stack = nullptr, ContextTrace *context = nullptr);
String DiagnosticInformation(const boost::exception_ptr& eptr, bool verbose = true);
String DiagnosticInformation(const std::exception_ptr& eptr, bool verbose = true);

class posix_error : virtual public std::exception, virtual public boost::exception {
public:
Expand Down
6 changes: 3 additions & 3 deletions lib/base/workqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ bool WorkQueue::HasExceptions() const
* Returns all exceptions which have occurred for tasks in this work queue. When a
* custom exception callback is set this method will always return an empty list.
*/
std::vector<boost::exception_ptr> WorkQueue::GetExceptions() const
std::vector<std::exception_ptr> WorkQueue::GetExceptions() const
{
std::unique_lock<std::mutex> lock(m_Mutex);

Expand All @@ -172,7 +172,7 @@ std::vector<boost::exception_ptr> WorkQueue::GetExceptions() const

void WorkQueue::ReportExceptions(const String& facility, bool verbose) const
{
std::vector<boost::exception_ptr> exceptions = GetExceptions();
std::vector<std::exception_ptr> exceptions = GetExceptions();

for (const auto& eptr : exceptions) {
Log(LogCritical, facility)
Expand Down Expand Up @@ -236,7 +236,7 @@ void WorkQueue::RunTaskFunction(const TaskFunction& func)
try {
func();
} catch (const std::exception&) {
boost::exception_ptr eptr = boost::current_exception();
std::exception_ptr eptr = std::current_exception();

{
std::unique_lock<std::mutex> mutex(m_Mutex);
Expand Down
7 changes: 3 additions & 4 deletions lib/base/workqueue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "base/ringbuffer.hpp"
#include "base/logger.hpp"
#include <boost/thread/thread.hpp>
#include <boost/exception_ptr.hpp>
#include <condition_variable>
#include <mutex>
#include <queue>
Expand Down Expand Up @@ -52,7 +51,7 @@ bool operator<(const Task& a, const Task& b);
class WorkQueue
{
public:
typedef std::function<void (boost::exception_ptr)> ExceptionCallback;
using ExceptionCallback = std::function<void(std::exception_ptr)>;

WorkQueue(size_t maxItems = 0, int threadCount = 1, LogSeverity statsLogLevel = LogInformation);
~WorkQueue();
Expand Down Expand Up @@ -113,7 +112,7 @@ class WorkQueue
void SetExceptionCallback(const ExceptionCallback& callback);

bool HasExceptions() const;
std::vector<boost::exception_ptr> GetExceptions() const;
std::vector<std::exception_ptr> GetExceptions() const;
void ReportExceptions(const String& facility, bool verbose = false) const;

protected:
Expand All @@ -137,7 +136,7 @@ class WorkQueue
std::priority_queue<Task, std::deque<Task> > m_Tasks;
int m_NextTaskID{0};
ExceptionCallback m_ExceptionCallback;
std::vector<boost::exception_ptr> m_Exceptions;
std::vector<std::exception_ptr> m_Exceptions;
Timer::Ptr m_StatusTimer;
double m_StatusTimerTimeout;
LogSeverity m_StatsLogLevel;
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/consolecommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ int ConsoleCommand::RunScriptConsole(ScriptFrame& scriptFrame, const String& con
result = ExecuteScript(l_Session, command, scriptFrame.Sandboxed);
} catch (const ScriptError&) {
/* Re-throw the exception for the outside try-catch block. */
boost::rethrow_exception(boost::current_exception());
throw;
} catch (const std::exception& ex) {
Log(LogCritical, "ConsoleCommand")
<< "HTTP query failed: " << ex.what();
Expand Down
4 changes: 2 additions & 2 deletions lib/db_ido_mysql/idomysqlconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void IdoMysqlConnection::Resume()

SetConnected(false);

m_QueryQueue.SetExceptionCallback([this](boost::exception_ptr exp) { ExceptionHandler(std::move(exp)); });
m_QueryQueue.SetExceptionCallback([this](std::exception_ptr exp) { ExceptionHandler(std::move(exp)); });

/* Immediately try to connect on Resume() without timer. */
m_QueryQueue.Enqueue([this]() { Reconnect(); }, PriorityImmediate);
Expand Down Expand Up @@ -130,7 +130,7 @@ void IdoMysqlConnection::Pause()

}

void IdoMysqlConnection::ExceptionHandler(boost::exception_ptr exp)
void IdoMysqlConnection::ExceptionHandler(std::exception_ptr exp)
{
Log(LogCritical, "IdoMysqlConnection", "Exception during database operation: Verify that your database is operational!");

Expand Down
2 changes: 1 addition & 1 deletion lib/db_ido_mysql/idomysqlconnection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class IdoMysqlConnection final : public ObjectImpl<IdoMysqlConnection>
void ClearTableBySession(const String& table);
void ClearTablesBySession();

void ExceptionHandler(boost::exception_ptr exp);
void ExceptionHandler(std::exception_ptr exp);

void FinishConnect(double startTime);
};
Expand Down
4 changes: 2 additions & 2 deletions lib/db_ido_pgsql/idopgsqlconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void IdoPgsqlConnection::Resume()

SetConnected(false);

m_QueryQueue.SetExceptionCallback([this](boost::exception_ptr exp) { ExceptionHandler(std::move(exp)); });
m_QueryQueue.SetExceptionCallback([this](std::exception_ptr exp) { ExceptionHandler(std::move(exp)); });

/* Immediately try to connect on Resume() without timer. */
m_QueryQueue.Enqueue([this]() { Reconnect(); }, PriorityImmediate);
Expand Down Expand Up @@ -129,7 +129,7 @@ void IdoPgsqlConnection::Pause()
<< "'" << GetName() << "' paused.";
}

void IdoPgsqlConnection::ExceptionHandler(boost::exception_ptr exp)
void IdoPgsqlConnection::ExceptionHandler(std::exception_ptr exp)
{
Log(LogWarning, "IdoPgsqlConnection", "Exception during database operation: Verify that your database is operational!");

Expand Down
2 changes: 1 addition & 1 deletion lib/db_ido_pgsql/idopgsqlconnection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class IdoPgsqlConnection final : public ObjectImpl<IdoPgsqlConnection>
void ClearTableBySession(const String& table);
void ClearTablesBySession();

void ExceptionHandler(boost::exception_ptr exp);
void ExceptionHandler(std::exception_ptr exp);

void FinishConnect(double startTime);
};
Expand Down
8 changes: 4 additions & 4 deletions lib/icingadb/icingadb-objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,9 @@ void IcingaDB::UpdateAllConfigObjects()
upqObjectType.Join();

if (upqObjectType.HasExceptions()) {
for (boost::exception_ptr exc : upqObjectType.GetExceptions()) {
for (std::exception_ptr exc : upqObjectType.GetExceptions()) {
if (exc) {
boost::rethrow_exception(exc);
std::rethrow_exception(exc);
}
}
}
Expand Down Expand Up @@ -512,10 +512,10 @@ void IcingaDB::UpdateAllConfigObjects()
upq.Join();

if (upq.HasExceptions()) {
for (boost::exception_ptr exc : upq.GetExceptions()) {
for (std::exception_ptr exc : upq.GetExceptions()) {
try {
if (exc) {
boost::rethrow_exception(exc);
std::rethrow_exception(exc);
}
} catch(const std::exception& e) {
Log(LogCritical, "IcingaDB")
Expand Down
4 changes: 2 additions & 2 deletions lib/icingadb/icingadb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void IcingaDB::Start(bool runtimeCreated)
m_ConfigDumpInProgress = false;
m_ConfigDumpDone = false;

m_WorkQueue.SetExceptionCallback([this](boost::exception_ptr exp) { ExceptionHandler(std::move(exp)); });
m_WorkQueue.SetExceptionCallback([this](std::exception_ptr exp) { ExceptionHandler(std::move(exp)); });

RedisConnInfo::ConstPtr connInfo = GetRedisConnInfo();

Expand Down Expand Up @@ -130,7 +130,7 @@ void IcingaDB::Start(bool runtimeCreated)
m_PendingItemsThread = std::thread([this, keepAlive] { PendingItemsThreadProc(); });
}

void IcingaDB::ExceptionHandler(boost::exception_ptr exp)
void IcingaDB::ExceptionHandler(std::exception_ptr exp)
{
Log(LogCritical, "IcingaDB", "Exception during redis query. Verify that Redis is operational.");

Expand Down
2 changes: 1 addition & 1 deletion lib/icingadb/icingadb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ class IcingaDB : public ObjectImpl<IcingaDB>

void AssertOnWorkQueue();

void ExceptionHandler(boost::exception_ptr exp);
void ExceptionHandler(std::exception_ptr exp);

using SyncableTypeInfo = std::pair<const Type::Ptr, QueryArgPair>;
static std::vector<SyncableTypeInfo> GetSyncableTypes();
Expand Down
4 changes: 2 additions & 2 deletions lib/perfdata/elasticsearchwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void ElasticsearchWriter::Resume()
Log(LogInformation, "ElasticsearchWriter")
<< "'" << GetName() << "' resumed.";

m_WorkQueue.SetExceptionCallback([this](boost::exception_ptr exp) { ExceptionHandler(std::move(exp)); });
m_WorkQueue.SetExceptionCallback([this](std::exception_ptr exp) { ExceptionHandler(std::move(exp)); });

/* Setup timer for periodically flushing m_DataBuffer */
m_FlushTimer = Timer::Create();
Expand Down Expand Up @@ -576,7 +576,7 @@ void ElasticsearchWriter::AssertOnWorkQueue()
ASSERT(m_WorkQueue.IsWorkerThread());
}

void ElasticsearchWriter::ExceptionHandler(boost::exception_ptr exp)
void ElasticsearchWriter::ExceptionHandler(std::exception_ptr exp)
{
Log(LogCritical, "ElasticsearchWriter", "Exception during Elastic operation: Verify that your backend is operational!");

Expand Down
2 changes: 1 addition & 1 deletion lib/perfdata/elasticsearchwriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ElasticsearchWriter final : public ObjectImpl<ElasticsearchWriter>
const Dictionary::Ptr& fields, double ts);

void AssertOnWorkQueue();
void ExceptionHandler(boost::exception_ptr exp);
void ExceptionHandler(std::exception_ptr exp);
void FlushTimeout();
void Flush();
void SendRequest(const String& body);
Expand Down
4 changes: 2 additions & 2 deletions lib/perfdata/gelfwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void GelfWriter::Resume()
<< "'" << GetName() << "' resumed.";

/* Register exception handler for WQ tasks. */
m_WorkQueue.SetExceptionCallback([this](boost::exception_ptr exp) { ExceptionHandler(std::move(exp)); });
m_WorkQueue.SetExceptionCallback([this](std::exception_ptr exp) { ExceptionHandler(std::move(exp)); });

m_Connection = new PerfdataWriterConnection{this, GetHost(), GetPort(), m_SslContext, !GetInsecureNoverify()};
m_LockedConnection.store(m_Connection);
Expand Down Expand Up @@ -139,7 +139,7 @@ void GelfWriter::AssertOnWorkQueue()
ASSERT(m_WorkQueue.IsWorkerThread());
}

void GelfWriter::ExceptionHandler(boost::exception_ptr exp)
void GelfWriter::ExceptionHandler(std::exception_ptr exp)
{
Log(LogCritical, "GelfWriter") << "Exception during Graylog Gelf operation: " << DiagnosticInformation(exp, false);
Log(LogDebug, "GelfWriter") << "Exception during Graylog Gelf operation: " << DiagnosticInformation(exp, true);
Expand Down
2 changes: 1 addition & 1 deletion lib/perfdata/gelfwriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class GelfWriter final : public ObjectImpl<GelfWriter>

void AssertOnWorkQueue();

void ExceptionHandler(boost::exception_ptr exp);
void ExceptionHandler(std::exception_ptr exp);
};

}
Expand Down
4 changes: 2 additions & 2 deletions lib/perfdata/graphitewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void GraphiteWriter::Resume()
<< "'" << GetName() << "' resumed.";

/* Register exception handler for WQ tasks. */
m_WorkQueue.SetExceptionCallback([this](boost::exception_ptr exp) { ExceptionHandler(std::move(exp)); });
m_WorkQueue.SetExceptionCallback([this](std::exception_ptr exp) { ExceptionHandler(std::move(exp)); });

m_Connection = new PerfdataWriterConnection{this, GetHost(), GetPort()};
m_LockedConnection.store(m_Connection);
Expand Down Expand Up @@ -135,7 +135,7 @@ void GraphiteWriter::AssertOnWorkQueue()
*
* @param exp Exception pointer
*/
void GraphiteWriter::ExceptionHandler(boost::exception_ptr exp)
void GraphiteWriter::ExceptionHandler(std::exception_ptr exp)
{
Log(LogCritical, "GraphiteWriter", "Exception during Graphite operation: Verify that your backend is operational!");

Expand Down
2 changes: 1 addition & 1 deletion lib/perfdata/graphitewriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class GraphiteWriter final : public ObjectImpl<GraphiteWriter>

void AssertOnWorkQueue();

void ExceptionHandler(boost::exception_ptr exp);
void ExceptionHandler(std::exception_ptr exp);
};

}
Expand Down
4 changes: 2 additions & 2 deletions lib/perfdata/influxdbcommonwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void InfluxdbCommonWriter::Resume()
<< "'" << GetName() << "' resumed.";

/* Register exception handler for WQ tasks. */
m_WorkQueue.SetExceptionCallback([this](boost::exception_ptr exp) { ExceptionHandler(std::move(exp)); });
m_WorkQueue.SetExceptionCallback([this](std::exception_ptr exp) { ExceptionHandler(std::move(exp)); });

/* Setup timer for periodically flushing m_DataBuffer */
m_FlushTimer = Timer::Create();
Expand Down Expand Up @@ -135,7 +135,7 @@ void InfluxdbCommonWriter::AssertOnWorkQueue()
ASSERT(m_WorkQueue.IsWorkerThread());
}

void InfluxdbCommonWriter::ExceptionHandler(boost::exception_ptr exp)
void InfluxdbCommonWriter::ExceptionHandler(std::exception_ptr exp)
{
Log(LogCritical, GetReflectionType()->GetName(), "Exception during InfluxDB operation: Verify that your backend is operational!");

Expand Down
2 changes: 1 addition & 1 deletion lib/perfdata/influxdbcommonwriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class InfluxdbCommonWriter : public ObjectImpl<InfluxdbCommonWriter>

void AssertOnWorkQueue();

void ExceptionHandler(boost::exception_ptr exp);
void ExceptionHandler(std::exception_ptr exp);
};

template<class InfluxWriter>
Expand Down
2 changes: 1 addition & 1 deletion lib/perfdata/opentsdbwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void OpenTsdbWriter::Resume()
Log(LogInformation, "OpentsdbWriter")
<< "'" << GetName() << "' resumed.";

m_WorkQueue.SetExceptionCallback([](const boost::exception_ptr& exp) {
m_WorkQueue.SetExceptionCallback([](const std::exception_ptr& exp) {
Log(LogDebug, "OpenTsdbWriter")
<< "Exception during OpenTsdb operation: " << DiagnosticInformation(exp);
});
Expand Down
2 changes: 1 addition & 1 deletion lib/perfdata/otlpmetricswriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void OTLPMetricsWriter::Resume()
Log(LogInformation, "OTLPMetricsWriter")
<< "'" << GetName() << "' resumed.";

m_WorkQueue.SetExceptionCallback([](boost::exception_ptr exp) {
m_WorkQueue.SetExceptionCallback([](std::exception_ptr exp) {
Log(LogCritical, "OTLPMetricsWriter")
<< "Exception while producing OTel metric: " << DiagnosticInformation(exp);
});
Expand Down
6 changes: 2 additions & 4 deletions lib/remote/actionshandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ bool ActionsHandler::HandleRequest(
} catch (const MissingPermissionError& ex) {
HttpUtility::SendJsonError(response, params, 403, ex.what());
return true;
} catch (const std::exception& ex) {
HttpUtility::SendJsonError(response, params, 404,
"No objects found.",
DiagnosticInformation(ex));
} catch (const std::exception&) {
HttpUtility::SendJsonError(response, params, 404, "No objects found.", std::current_exception());
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/remote/configfileshandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ bool ConfigFilesHandler::HandleRequest(
response.result(http::status::ok);
response.set(http::field::content_type, "application/octet-stream");
response.SendFile(path, yc);
} catch (const std::ios_base::failure& ex) {
} catch (const std::ios_base::failure&) {
if (response.HasSerializationStarted()) {
throw;
}

HttpUtility::SendJsonError(response, params, 500, "Could not read file.", DiagnosticInformation(ex));
HttpUtility::SendJsonError(response, params, 500, "Could not read file.", std::current_exception());
}

return true;
Expand Down
4 changes: 2 additions & 2 deletions lib/remote/configobjectutility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
Log(LogNotice, "ConfigObjectUtility")
<< "Failed to commit config item '" << fullName << "'. Aborting and removing config path '" << path << "'.";

for (const boost::exception_ptr& ex : upq.GetExceptions()) {
for (const std::exception_ptr& ex : upq.GetExceptions()) {
errors->Add(DiagnosticInformation(ex, false));

if (diagnosticInformation)
Expand All @@ -256,7 +256,7 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
Log(LogNotice, "ConfigObjectUtility")
<< "Failed to activate config object '" << fullName << "'. Aborting and removing config path '" << path << "'.";

for (const boost::exception_ptr& ex : upq.GetExceptions()) {
for (const std::exception_ptr& ex : upq.GetExceptions()) {
errors->Add(DiagnosticInformation(ex, false));

if (diagnosticInformation)
Expand Down
Loading
Loading