diff --git a/icinga-studio/mainform.cpp b/icinga-studio/mainform.cpp index 4dd5c4c04..ebaf6e4a0 100644 --- a/icinga-studio/mainform.cpp +++ b/icinga-studio/mainform.cpp @@ -49,7 +49,7 @@ MainForm::MainForm(wxWindow *parent, const Url::Ptr& url) m_PropertyGrid->SetColumnCount(3); } -void MainForm::TypesCompletionHandler(std::exception_ptr eptr, const std::vector& types, bool forward) +void MainForm::TypesCompletionHandler(boost::exception_ptr eptr, const std::vector& types, bool forward) { if (forward) { CallAfter(boost::bind(&MainForm::TypesCompletionHandler, this, eptr, types, false)); @@ -60,7 +60,7 @@ void MainForm::TypesCompletionHandler(std::exception_ptr eptr, const std::vector if (eptr) { try { - std::rethrow_exception(eptr); + boost::rethrow_exception(eptr); } catch (const std::exception& ex) { std::string message = "HTTP query failed: " + std::string(ex.what()); wxMessageBox(message, "Icinga Studio", wxOK | wxCENTRE | wxICON_ERROR, this); @@ -122,7 +122,7 @@ static bool ApiObjectLessComparer(const ApiObject::Ptr& o1, const ApiObject::Ptr return o1->Name < o2->Name; } -void MainForm::ObjectsCompletionHandler(std::exception_ptr eptr, const std::vector& objects, bool forward) +void MainForm::ObjectsCompletionHandler(boost::exception_ptr eptr, const std::vector& objects, bool forward) { if (forward) { CallAfter(boost::bind(&MainForm::ObjectsCompletionHandler, this, eptr, objects, false)); @@ -134,7 +134,7 @@ void MainForm::ObjectsCompletionHandler(std::exception_ptr eptr, const std::vect if (eptr) { try { - std::rethrow_exception(eptr); + boost::rethrow_exception(eptr); } catch (const std::exception& ex) { std::string message = "HTTP query failed: " + std::string(ex.what()); wxMessageBox(message, "Icinga Studio", wxOK | wxCENTRE | wxICON_ERROR, this); @@ -236,7 +236,7 @@ wxPGProperty *MainForm::ValueToProperty(const String& name, const Value& value) } } -void MainForm::ObjectDetailsCompletionHandler(std::exception_ptr eptr, const std::vector& objects, bool forward) +void MainForm::ObjectDetailsCompletionHandler(boost::exception_ptr eptr, const std::vector& objects, bool forward) { if (forward) { CallAfter(boost::bind(&MainForm::ObjectDetailsCompletionHandler, this, eptr, objects, false)); @@ -247,7 +247,7 @@ void MainForm::ObjectDetailsCompletionHandler(std::exception_ptr eptr, const std if (eptr) { try { - std::rethrow_exception(eptr); + boost::rethrow_exception(eptr); } catch (const std::exception& ex) { std::string message = "HTTP query failed: " + std::string(ex.what()); wxMessageBox(message, "Icinga Studio", wxOK | wxCENTRE | wxICON_ERROR, this); diff --git a/icinga-studio/mainform.hpp b/icinga-studio/mainform.hpp index a7b0b2891..a4dcaa28f 100644 --- a/icinga-studio/mainform.hpp +++ b/icinga-studio/mainform.hpp @@ -42,9 +42,9 @@ private: ApiClient::Ptr m_ApiClient; std::map m_Types; - void TypesCompletionHandler(std::exception_ptr eptr, const std::vector& types, bool forward); - void ObjectsCompletionHandler(std::exception_ptr eptr, const std::vector& objects, bool forward); - void ObjectDetailsCompletionHandler(std::exception_ptr eptr, const std::vector& objects, bool forward); + void TypesCompletionHandler(boost::exception_ptr eptr, const std::vector& types, bool forward); + void ObjectsCompletionHandler(boost::exception_ptr eptr, const std::vector& objects, bool forward); + void ObjectDetailsCompletionHandler(boost::exception_ptr eptr, const std::vector& objects, bool forward); wxPGProperty *ValueToProperty(const String& name, const Value& value); }; diff --git a/lib/base/exception.cpp b/lib/base/exception.cpp index 2b21a4664..5062ae4a6 100644 --- a/lib/base/exception.cpp +++ b/lib/base/exception.cpp @@ -260,7 +260,7 @@ String icinga::DiagnosticInformation(const std::exception& ex, bool verbose, Sta return result.str(); } -String icinga::DiagnosticInformation(std::exception_ptr eptr, bool verbose) +String icinga::DiagnosticInformation(boost::exception_ptr eptr, bool verbose) { StackTrace *pt = GetLastExceptionStack(); StackTrace stack; @@ -275,7 +275,7 @@ String icinga::DiagnosticInformation(std::exception_ptr eptr, bool verbose) context = *pc; try { - std::rethrow_exception(eptr); + boost::rethrow_exception(eptr); } catch (const std::exception& ex) { return DiagnosticInformation(ex, verbose, pt ? &stack : NULL, pc ? &context : NULL); } diff --git a/lib/base/exception.hpp b/lib/base/exception.hpp index 1901af542..04b20be24 100644 --- a/lib/base/exception.hpp +++ b/lib/base/exception.hpp @@ -29,11 +29,11 @@ #include "base/dictionary.hpp" #include "base/configobject.hpp" #include -#include #include #include #include #include +#include #ifdef _WIN32 # include @@ -121,7 +121,7 @@ inline std::string to_string(const ContextTraceErrorInfo& e) } I2_BASE_API String DiagnosticInformation(const std::exception& ex, bool verbose = true, StackTrace *stack = NULL, ContextTrace *context = NULL); -I2_BASE_API String DiagnosticInformation(std::exception_ptr eptr, bool verbose = true); +I2_BASE_API String DiagnosticInformation(boost::exception_ptr eptr, bool verbose = true); class I2_BASE_API posix_error : virtual public std::exception, virtual public boost::exception { public: diff --git a/lib/base/json.cpp b/lib/base/json.cpp index 74fab8753..6362e8b24 100644 --- a/lib/base/json.cpp +++ b/lib/base/json.cpp @@ -23,11 +23,11 @@ #include "base/array.hpp" #include "base/objectlock.hpp" #include "base/convert.hpp" +#include #include #include #include #include -#include using namespace icinga; @@ -188,19 +188,19 @@ public: void SaveException(void) { - m_Exception = std::current_exception(); + m_Exception = boost::current_exception(); } void ThrowException(void) const { if (m_Exception) - std::rethrow_exception(m_Exception); + boost::rethrow_exception(m_Exception); } private: std::stack m_Stack; Value m_Key; - std::exception_ptr m_Exception; + boost::exception_ptr m_Exception; }; static int DecodeNull(void *ctx) diff --git a/lib/base/workqueue.cpp b/lib/base/workqueue.cpp index 38b5b76ab..1ded9c150 100644 --- a/lib/base/workqueue.cpp +++ b/lib/base/workqueue.cpp @@ -161,7 +161,7 @@ bool WorkQueue::HasExceptions(void) 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 WorkQueue::GetExceptions(void) const +std::vector WorkQueue::GetExceptions(void) const { boost::mutex::scoped_lock lock(m_Mutex); @@ -170,7 +170,7 @@ std::vector WorkQueue::GetExceptions(void) const void WorkQueue::ReportExceptions(const String& facility) const { - std::vector exceptions = GetExceptions(); + std::vector exceptions = GetExceptions(); for (const auto& eptr : exceptions) { Log(LogCritical, facility) @@ -235,12 +235,12 @@ void WorkQueue::WorkerThreadProc(void) lock.lock(); if (!m_ExceptionCallback) - m_Exceptions.push_back(std::current_exception()); + m_Exceptions.push_back(boost::current_exception()); lock.unlock(); if (m_ExceptionCallback) - m_ExceptionCallback(std::current_exception()); + m_ExceptionCallback(boost::current_exception()); } /* clear the task so whatever other resources it holds are released diff --git a/lib/base/workqueue.hpp b/lib/base/workqueue.hpp index 3f2a498f0..77d0c17a4 100644 --- a/lib/base/workqueue.hpp +++ b/lib/base/workqueue.hpp @@ -26,9 +26,9 @@ #include #include #include +#include #include #include -#include namespace icinga { @@ -78,7 +78,7 @@ inline bool operator<(const Task& a, const Task& b) class I2_BASE_API WorkQueue { public: - typedef boost::function ExceptionCallback; + typedef boost::function ExceptionCallback; WorkQueue(size_t maxItems = 0, int threadCount = 1); ~WorkQueue(void); @@ -97,7 +97,7 @@ public: void SetExceptionCallback(const ExceptionCallback& callback); bool HasExceptions(void) const; - std::vector GetExceptions(void) const; + std::vector GetExceptions(void) const; void ReportExceptions(const String& facility) const; private: @@ -118,7 +118,7 @@ private: std::priority_queue > m_Tasks; int m_NextTaskID; ExceptionCallback m_ExceptionCallback; - std::vector m_Exceptions; + std::vector m_Exceptions; Timer::Ptr m_StatusTimer; void WorkerThreadProc(void); diff --git a/lib/cli/consolecommand.cpp b/lib/cli/consolecommand.cpp index b9e1dfeee..421e9fd2c 100644 --- a/lib/cli/consolecommand.cpp +++ b/lib/cli/consolecommand.cpp @@ -378,7 +378,7 @@ incomplete: boost::mutex mutex; boost::condition_variable cv; bool ready = false; - std::exception_ptr eptr; + boost::exception_ptr eptr; l_ApiClient->ExecuteScript(l_Session, command, scriptFrame.Sandboxed, boost::bind(&ConsoleCommand::ExecuteScriptCompletionHandler, @@ -393,7 +393,7 @@ incomplete: } if (eptr) - std::rethrow_exception(eptr); + boost::rethrow_exception(eptr); } if (commandOnce.IsEmpty()) { @@ -466,13 +466,13 @@ incomplete: } void ConsoleCommand::ExecuteScriptCompletionHandler(boost::mutex& mutex, boost::condition_variable& cv, - bool& ready, std::exception_ptr eptr, const Value& result, Value& resultOut, std::exception_ptr& eptrOut) + bool& ready, boost::exception_ptr eptr, const Value& result, Value& resultOut, boost::exception_ptr& eptrOut) { if (eptr) { try { - std::rethrow_exception(eptr); + boost::rethrow_exception(eptr); } catch (const ScriptError& ex) { - eptrOut = std::current_exception(); + eptrOut = boost::current_exception(); } catch (const std::exception& ex) { Log(LogCritical, "ConsoleCommand") << "HTTP query failed: " << ex.what(); @@ -490,11 +490,11 @@ void ConsoleCommand::ExecuteScriptCompletionHandler(boost::mutex& mutex, boost:: } void ConsoleCommand::AutocompleteScriptCompletionHandler(boost::mutex& mutex, boost::condition_variable& cv, - bool& ready, std::exception_ptr eptr, const Array::Ptr& result, Array::Ptr& resultOut) + bool& ready, boost::exception_ptr eptr, const Array::Ptr& result, Array::Ptr& resultOut) { if (eptr) { try { - std::rethrow_exception(eptr); + boost::rethrow_exception(eptr); } catch (const std::exception& ex) { Log(LogCritical, "ConsoleCommand") << "HTTP query failed: " << ex.what(); diff --git a/lib/cli/consolecommand.hpp b/lib/cli/consolecommand.hpp index 7b52b2252..331f226a4 100644 --- a/lib/cli/consolecommand.hpp +++ b/lib/cli/consolecommand.hpp @@ -54,10 +54,10 @@ private: mutable boost::condition_variable m_CV; static void ExecuteScriptCompletionHandler(boost::mutex& mutex, boost::condition_variable& cv, - bool& ready, std::exception_ptr eptr, const Value& result, Value& resultOut, - std::exception_ptr& eptrOut); + bool& ready, boost::exception_ptr eptr, const Value& result, Value& resultOut, + boost::exception_ptr& eptrOut); static void AutocompleteScriptCompletionHandler(boost::mutex& mutex, boost::condition_variable& cv, - bool& ready, std::exception_ptr eptr, const Array::Ptr& result, Array::Ptr& resultOut); + bool& ready, boost::exception_ptr eptr, const Array::Ptr& result, Array::Ptr& resultOut); #ifdef HAVE_EDITLINE static char *ConsoleCompleteHelper(const char *word, int state); diff --git a/lib/config/expression.cpp b/lib/config/expression.cpp index 1f6ed8348..0930a9129 100644 --- a/lib/config/expression.cpp +++ b/lib/config/expression.cpp @@ -28,6 +28,8 @@ #include "base/exception.hpp" #include "base/scriptglobal.hpp" #include "base/loader.hpp" +#include +#include using namespace icinga; @@ -70,7 +72,8 @@ ExpressionResult Expression::Evaluate(ScriptFrame& frame, DebugHint *dhint) cons } catch (const std::exception& ex) { frame.DecreaseStackDepth(); - BOOST_THROW_EXCEPTION(ScriptError("Error while evaluating expression: " + String(ex.what()), GetDebugInfo())); + BOOST_THROW_EXCEPTION(ScriptError("Error while evaluating expression: " + String(ex.what()), GetDebugInfo()) + << boost::errinfo_nested_exception(boost::current_exception())); } frame.DecreaseStackDepth(); diff --git a/lib/db_ido_mysql/idomysqlconnection.cpp b/lib/db_ido_mysql/idomysqlconnection.cpp index 638eb7d44..7b4153932 100644 --- a/lib/db_ido_mysql/idomysqlconnection.cpp +++ b/lib/db_ido_mysql/idomysqlconnection.cpp @@ -105,7 +105,7 @@ void IdoMysqlConnection::Pause(void) m_QueryQueue.Join(); } -void IdoMysqlConnection::ExceptionHandler(std::exception_ptr exp) +void IdoMysqlConnection::ExceptionHandler(boost::exception_ptr exp) { Log(LogCritical, "IdoMysqlConnection", "Exception during database operation: Verify that your database is operational!"); diff --git a/lib/db_ido_mysql/idomysqlconnection.hpp b/lib/db_ido_mysql/idomysqlconnection.hpp index 0b62aa27e..c134cf7fe 100644 --- a/lib/db_ido_mysql/idomysqlconnection.hpp +++ b/lib/db_ido_mysql/idomysqlconnection.hpp @@ -117,7 +117,7 @@ private: void ClearTableBySession(const String& table); void ClearTablesBySession(void); - void ExceptionHandler(std::exception_ptr exp); + void ExceptionHandler(boost::exception_ptr exp); void FinishConnect(double startTime); }; diff --git a/lib/db_ido_pgsql/idopgsqlconnection.cpp b/lib/db_ido_pgsql/idopgsqlconnection.cpp index 18feaeb81..7e5250593 100644 --- a/lib/db_ido_pgsql/idopgsqlconnection.cpp +++ b/lib/db_ido_pgsql/idopgsqlconnection.cpp @@ -109,7 +109,7 @@ void IdoPgsqlConnection::Pause(void) m_QueryQueue.Join(); } -void IdoPgsqlConnection::ExceptionHandler(std::exception_ptr exp) +void IdoPgsqlConnection::ExceptionHandler(boost::exception_ptr exp) { Log(LogWarning, "IdoPgsqlConnection", "Exception during database operation: Verify that your database is operational!"); diff --git a/lib/db_ido_pgsql/idopgsqlconnection.hpp b/lib/db_ido_pgsql/idopgsqlconnection.hpp index cc3fffd53..62fd2a966 100644 --- a/lib/db_ido_pgsql/idopgsqlconnection.hpp +++ b/lib/db_ido_pgsql/idopgsqlconnection.hpp @@ -102,7 +102,7 @@ private: void ClearTableBySession(const String& table); void ClearTablesBySession(void); - void ExceptionHandler(std::exception_ptr exp); + void ExceptionHandler(boost::exception_ptr exp); void FinishConnect(double startTime); }; diff --git a/lib/remote/apiclient.cpp b/lib/remote/apiclient.cpp index 4c46f3e17..34ebb4508 100644 --- a/lib/remote/apiclient.cpp +++ b/lib/remote/apiclient.cpp @@ -53,7 +53,7 @@ void ApiClient::GetTypes(const TypesCompletionCallback& callback) const req->AddHeader("Accept", "application/json"); m_Connection->SubmitRequest(req, boost::bind(TypesHttpCompletionCallback, _1, _2, callback)); } catch (const std::exception& ex) { - callback(std::current_exception(), std::vector()); + callback(boost::current_exception(), std::vector()); } } @@ -94,11 +94,11 @@ void ApiClient::TypesHttpCompletionCallback(HttpRequest& request, HttpResponse& types.push_back(type); } - callback(std::exception_ptr(), types); + callback(boost::exception_ptr(), types); } catch (const std::exception& ex) { Log(LogCritical, "ApiClient") << "Error while decoding response: " << DiagnosticInformation(ex); - callback(std::current_exception(), std::vector()); + callback(boost::current_exception(), std::vector()); } } @@ -143,7 +143,7 @@ void ApiClient::GetObjects(const String& pluralType, const ObjectsCompletionCall req->AddHeader("Accept", "application/json"); m_Connection->SubmitRequest(req, boost::bind(ObjectsHttpCompletionCallback, _1, _2, callback)); } catch (const std::exception& ex) { - callback(std::current_exception(), std::vector()); + callback(boost::current_exception(), std::vector()); } } @@ -221,11 +221,11 @@ void ApiClient::ObjectsHttpCompletionCallback(HttpRequest& request, } } - callback(std::exception_ptr(), objects); + callback(boost::exception_ptr(), objects); } catch (const std::exception& ex) { Log(LogCritical, "ApiClient") << "Error while decoding response: " << DiagnosticInformation(ex); - callback(std::current_exception(), std::vector()); + callback(boost::current_exception(), std::vector()); } } @@ -257,7 +257,7 @@ void ApiClient::ExecuteScript(const String& session, const String& command, bool req->AddHeader("Accept", "application/json"); m_Connection->SubmitRequest(req, boost::bind(ExecuteScriptHttpCompletionCallback, _1, _2, callback)); } catch (const std::exception& ex) { - callback(std::current_exception(), Empty); + callback(boost::current_exception(), Empty); } } @@ -307,9 +307,9 @@ void ApiClient::ExecuteScriptHttpCompletionCallback(HttpRequest& request, } } - callback(std::exception_ptr(), result); + callback(boost::exception_ptr(), result); } catch (const std::exception& ex) { - callback(std::current_exception(), Empty); + callback(boost::current_exception(), Empty); } } @@ -341,7 +341,7 @@ void ApiClient::AutocompleteScript(const String& session, const String& command, req->AddHeader("Accept", "application/json"); m_Connection->SubmitRequest(req, boost::bind(AutocompleteScriptHttpCompletionCallback, _1, _2, callback)); } catch (const std::exception& ex) { - callback(std::current_exception(), Array::Ptr()); + callback(boost::current_exception(), Array::Ptr()); } } @@ -380,8 +380,8 @@ void ApiClient::AutocompleteScriptHttpCompletionCallback(HttpRequest& request, BOOST_THROW_EXCEPTION(ScriptError(errorMessage)); } - callback(std::exception_ptr(), suggestions); + callback(boost::exception_ptr(), suggestions); } catch (const std::exception& ex) { - callback(std::current_exception(), Array::Ptr()); + callback(boost::current_exception(), Array::Ptr()); } } diff --git a/lib/remote/apiclient.hpp b/lib/remote/apiclient.hpp index f36d9f1c6..4d24da90d 100644 --- a/lib/remote/apiclient.hpp +++ b/lib/remote/apiclient.hpp @@ -92,20 +92,20 @@ public: ApiClient(const String& host, const String& port, const String& user, const String& password); - typedef boost::function&)> TypesCompletionCallback; + typedef boost::function&)> TypesCompletionCallback; void GetTypes(const TypesCompletionCallback& callback) const; - typedef boost::function&)> ObjectsCompletionCallback; + typedef boost::function&)> ObjectsCompletionCallback; void GetObjects(const String& pluralType, const ObjectsCompletionCallback& callback, const std::vector& names = std::vector(), const std::vector& attrs = std::vector(), const std::vector& joins = std::vector(), bool all_joins = false) const; - typedef boost::function ExecuteScriptCompletionCallback; + typedef boost::function ExecuteScriptCompletionCallback; void ExecuteScript(const String& session, const String& command, bool sandboxed, const ExecuteScriptCompletionCallback& callback) const; - typedef boost::function AutocompleteScriptCompletionCallback; + typedef boost::function AutocompleteScriptCompletionCallback; void AutocompleteScript(const String& session, const String& command, bool sandboxed, const AutocompleteScriptCompletionCallback& callback) const; diff --git a/lib/remote/configobjectutility.cpp b/lib/remote/configobjectutility.cpp index 3760c404e..f14b68096 100644 --- a/lib/remote/configobjectutility.cpp +++ b/lib/remote/configobjectutility.cpp @@ -143,7 +143,7 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full << boost::errinfo_file_name(path)); } - for (const std::exception_ptr& ex : upq.GetExceptions()) { + for (const boost::exception_ptr& ex : upq.GetExceptions()) { errors->Add(DiagnosticInformation(ex)); } }