]> granicus.if.org Git - icinga2/commitdiff
Extract exception error info message.
authorMichael Friedrich <michael.friedrich@netways.de>
Thu, 22 May 2014 12:41:27 +0000 (14:41 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Thu, 22 May 2014 14:07:57 +0000 (16:07 +0200)
Refs #6070

components/db_ido_mysql/idomysqlconnection.cpp
lib/base/exception.cpp
lib/base/exception.h
lib/remote/apilistener.cpp

index 5d05bca72641eee478a6ab198385ae681f3d77de..b4276e40f9a71e24d2ce0515c45bdfa0a206de5a 100644 (file)
@@ -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);
 
index 8c57a93af623d21333349cb1c087061cfe25d445..a262bbb97d5f4a0ba56ecf579288a5a7eac12658 100644 (file)
@@ -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();
+       }
+}
index 22b031508dffe07b12f77e309be9bcfe3c7c4cc9..d7cccc8ac722883dc7c613ba673b3e86246319cc 100644 (file)
@@ -84,7 +84,18 @@ String DiagnosticInformation(const T& ex, StackTrace *stack = NULL, ContextTrace
        return result.str();
 }
 
+template<typename T>
+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 { };
 
index 1612e749cf5a48854986193f6bfe994f6d4ef634..5037ee3065b8ae00152832952e590a73be635fc7 100644 (file)
@@ -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());