diff --git a/components/db_ido_mysql/idomysqlconnection.cpp b/components/db_ido_mysql/idomysqlconnection.cpp index 5d05bca72..b4276e40f 100644 --- a/components/db_ido_mysql/idomysqlconnection.cpp +++ b/components/db_ido_mysql/idomysqlconnection.cpp @@ -94,7 +94,8 @@ void IdoMysqlConnection::Pause(void) void IdoMysqlConnection::ExceptionHandler(boost::exception_ptr exp) { - Log(LogCritical, "db_ido_mysql", "Exception during database operation: " + DiagnosticInformation(exp)); + Log(LogCritical, "db_ido_mysql", "Exception during database operation: '" + ErrorInformation(exp) + "'"); + Log(LogDebug, "db_ido_mysql", "Exception during database operation: " + DiagnosticInformation(exp)); boost::mutex::scoped_lock lock(m_ConnectionMutex); diff --git a/lib/base/exception.cpp b/lib/base/exception.cpp index 8c57a93af..a262bbb97 100644 --- a/lib/base/exception.cpp +++ b/lib/base/exception.cpp @@ -152,3 +152,12 @@ String icinga::DiagnosticInformation(boost::exception_ptr eptr) return boost::diagnostic_information(eptr); } + +String icinga::ErrorInformation(boost::exception_ptr eptr) +{ + try { + boost::rethrow_exception(eptr); + } catch (const std::exception& ex) { + return ex.what(); + } +} diff --git a/lib/base/exception.h b/lib/base/exception.h index 22b031508..d7cccc8ac 100644 --- a/lib/base/exception.h +++ b/lib/base/exception.h @@ -84,7 +84,18 @@ String DiagnosticInformation(const T& ex, StackTrace *stack = NULL, ContextTrace return result.str(); } +template +String ErrorInformation(const T& ex) +{ + std::ostringstream result; + + result << ex.what(); + + return result.str(); +} + I2_BASE_API String DiagnosticInformation(boost::exception_ptr eptr); +I2_BASE_API String ErrorInformation(boost::exception_ptr eptr); class I2_BASE_API posix_error : virtual public std::exception, virtual public boost::exception { }; diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index 1612e749c..5037ee306 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -181,7 +181,7 @@ void ApiListener::AddConnection(const String& node, const String& service) Utility::QueueAsyncCallback(boost::bind(&ApiListener::NewClientHandler, this, client, RoleClient)); } catch (const std::exception& ex) { std::ostringstream info, debug; - info << "Cannot connect to host '" << node << "' on port '" << service << "'."; + info << "Cannot connect to host '" << node << "' on port '" << service << "'"; debug << info << std::endl << DiagnosticInformation(ex); Log(LogCritical, "remote", info.str()); Log(LogDebug, "remote", debug.str());