summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--inc/ABRTException.h37
-rw-r--r--inc/abrtlib.h2
-rw-r--r--lib/Plugins/FileTransfer.cpp4
-rw-r--r--src/Daemon/CommLayerServerDBus.cpp2
-rw-r--r--src/Daemon/Daemon.cpp4
-rw-r--r--src/Daemon/MiddleWare.cpp26
-rw-r--r--src/Daemon/PluginManager.cpp5
-rw-r--r--src/Hooks/CCpp.cpp2
8 files changed, 43 insertions, 39 deletions
diff --git a/inc/ABRTException.h b/inc/ABRTException.h
index 730faf3..173f45f 100644
--- a/inc/ABRTException.h
+++ b/inc/ABRTException.h
@@ -3,33 +3,40 @@
#include <string>
-typedef enum {EXCEP_UNKNOW,
- EXCEP_DD_OPEN,
- EXCEP_DD_LOAD,
- EXCEP_DD_SAVE,
- EXCEP_DD_DELETE,
- EXCEP_DL,
- EXCEP_PLUGIN,
- EXCEP_ERROR,
- EXCEP_FATAL} abrt_exception_t;
+typedef enum {
+ EXCEP_UNKNOW,
+ EXCEP_DD_OPEN,
+ EXCEP_DD_LOAD,
+ EXCEP_DD_SAVE,
+ EXCEP_DD_DELETE,
+ EXCEP_DL,
+ EXCEP_PLUGIN,
+ EXCEP_ERROR,
+ EXCEP_FATAL,
+} abrt_exception_t;
-class CABRTException : public std::exception
+/* std::exception is a class with virtual members.
+ * deriving from it makes our ctor/dtor much more heavy,
+ * and those are inlined in every throw and catch site!
+ */
+class CABRTException /*: public std::exception*/
{
private:
std::string m_sWhat;
abrt_exception_t m_Type;
+
public:
- virtual ~CABRTException() throw() {}
- CABRTException(const abrt_exception_t& pType, const char* pWhat) :
+ /* virtual ~CABRTException() throw() {} */
+ CABRTException(abrt_exception_t pType, const char* pWhat) :
m_sWhat(pWhat),
m_Type(pType)
{}
- CABRTException(const abrt_exception_t& pType, const std::string& pWhat) :
+ CABRTException(abrt_exception_t pType, const std::string& pWhat) :
m_sWhat(pWhat),
m_Type(pType)
{}
abrt_exception_t type() { return m_Type; }
- std::string what() { return m_sWhat; }
+ const char* what() const { return m_sWhat.c_str(); }
};
-#endif /* ABRTEXCEPTION_H_ */
+#endif
diff --git a/inc/abrtlib.h b/inc/abrtlib.h
index d20d067..9bcd5bf 100644
--- a/inc/abrtlib.h
+++ b/inc/abrtlib.h
@@ -212,7 +212,7 @@ std::string concat_path_file(const char *path, const char *filename);
template <class T>
std::string
-to_string( T x )
+to_string(T x)
{
std::ostringstream o;
o << x;
diff --git a/lib/Plugins/FileTransfer.cpp b/lib/Plugins/FileTransfer.cpp
index 856a326..8a88fef 100644
--- a/lib/Plugins/FileTransfer.cpp
+++ b/lib/Plugins/FileTransfer.cpp
@@ -332,7 +332,7 @@ void CFileTransfer::Run(const char *pActionDir, const char *pArgs)
}
catch (CABRTException& e)
{
- warn_client(_("CFileTransfer::Run(): Cannot create and send an archive: ") + e.what());
+ warn_client(ssprintf(_("Can't create and send an archive: %s"), e.what()));
//update_client("CFileTransfer::Run(): Cannot create and send an archive: " + e.what());
}
unlink(archivename.c_str());
@@ -358,7 +358,7 @@ void CFileTransfer::Run(const char *pActionDir, const char *pArgs)
}
catch (CABRTException& e)
{
- warn_client(_("CFileTransfer::Run(): Cannot create and send an archive: ") + e.what());
+ warn_client(ssprintf(_("Can't create and send an archive: "), e.what()));
// update_client("CFileTransfer::Run(): Cannot create and send an archive: " + e.what());
}
unlink(archivename.c_str());
diff --git a/src/Daemon/CommLayerServerDBus.cpp b/src/Daemon/CommLayerServerDBus.cpp
index 925844e..ed7e385 100644
--- a/src/Daemon/CommLayerServerDBus.cpp
+++ b/src/Daemon/CommLayerServerDBus.cpp
@@ -286,7 +286,7 @@ static int handle_Report(DBusMessage* call, DBusMessage* reply)
catch (CABRTException &e)
{
dbus_message_unref(reply);
- reply = dbus_message_new_error(call, DBUS_ERROR_FAILED, e.what().c_str());
+ reply = dbus_message_new_error(call, DBUS_ERROR_FAILED, e.what());
if (!reply)
die_out_of_memory();
send_flush_and_unref(reply);
diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp
index b417cfd..c6d0a02 100644
--- a/src/Daemon/Daemon.cpp
+++ b/src/Daemon/Daemon.cpp
@@ -415,7 +415,7 @@ static void FindNewDumps(const char* pPath)
{
throw e;
}
- error_msg("%s", e.what().c_str());
+ error_msg("%s", e.what());
}
}
}
@@ -883,7 +883,7 @@ int main(int argc, char** argv)
}
catch (CABRTException& e)
{
- error_msg("Error: %s", e.what().c_str());
+ error_msg("Error: %s", e.what());
}
catch (std::exception& e)
{
diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp
index abf1381..3f26ab0 100644
--- a/src/Daemon/MiddleWare.cpp
+++ b/src/Daemon/MiddleWare.cpp
@@ -236,7 +236,7 @@ mw_result_t CreateCrashReport(const char *pUUID,
}
catch (CABRTException& e)
{
- warn_client("CreateCrashReport(): " + e.what());
+ warn_client(e.what());
if (e.type() == EXCEP_DD_OPEN)
{
return MW_ERROR;
@@ -266,8 +266,8 @@ void RunAction(const char *pActionDir,
}
catch (CABRTException& e)
{
- warn_client(ssprintf("RunAction(): %s", e.what().c_str()));
- update_client(ssprintf("Execution of '%s' was not successful: %s", pPluginName, e.what().c_str()));
+ warn_client(ssprintf("RunAction(): %s", e.what()));
+ update_client(ssprintf("Execution of '%s' was not successful: %s", pPluginName, e.what()));
}
}
@@ -295,8 +295,8 @@ void RunActionsAndReporters(const char *pDebugDumpDir)
}
catch (CABRTException& e)
{
- warn_client("RunActionsAndReporters(): " + e.what());
- update_client("Activation of plugin '" + it_ar->first + "' was not successful: " + e.what());
+ warn_client(e.what());
+ update_client(ssprintf("Activation of plugin '%s' was not successful: %s", it_ar->first.c_str(), e.what()));
}
}
}
@@ -435,8 +435,7 @@ report_status_t Report(const map_crash_report_t& pCrashReport,
{
ret[pluginName].push_back("0");
ret[pluginName].push_back(e.what());
- warn_client("Report(): " + e.what());
- update_client("Reporting via '" + pluginName + "' was not successful: " + e.what());
+ update_client(ssprintf("Reporting via %s' was not successful: %s", pluginName.c_str(), e.what()));
}
}
}
@@ -565,7 +564,7 @@ static mw_result_t SavePackageDescriptionToDebugDump(const char *pExecutable,
}
catch (CABRTException& e)
{
- warn_client("SavePackageDescriptionToDebugDump(): " + e.what());
+ warn_client(e.what());
if (e.type() == EXCEP_DD_SAVE)
{
return MW_FILE_ERROR;
@@ -601,8 +600,7 @@ static void RunAnalyzerActions(const char *pAnalyzer, const char *pDebugDumpDir)
}
catch (CABRTException& e)
{
- warn_client("RunAnalyzerActions(): " + e.what());
- update_client("Action performed by '" + pluginName + "' was not successful: " + e.what());
+ update_client(ssprintf("Action performed by '%s' was not successful: %s", pluginName.c_str(), e.what()));
}
}
}
@@ -684,7 +682,7 @@ mw_result_t SaveDebugDump(const char *pDebugDumpDir,
}
catch (CABRTException& e)
{
- warn_client("SaveDebugDump(): " + e.what());
+ warn_client(e.what());
if (e.type() == EXCEP_DD_SAVE)
{
return MW_FILE_ERROR;
@@ -708,8 +706,8 @@ mw_result_t SaveDebugDump(const char *pDebugDumpDir,
}
mw_result_t GetCrashInfo(const char *pUUID,
- const char *pUID,
- map_crash_info_t& pCrashInfo)
+ const char *pUID,
+ map_crash_info_t& pCrashInfo)
{
pCrashInfo.clear();
CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase);
@@ -734,7 +732,7 @@ mw_result_t GetCrashInfo(const char *pUUID,
}
catch (CABRTException& e)
{
- warn_client("GetCrashInfo(): " + e.what());
+ warn_client(e.what());
if (e.type() == EXCEP_DD_LOAD)
{
return MW_FILE_ERROR;
diff --git a/src/Daemon/PluginManager.cpp b/src/Daemon/PluginManager.cpp
index 2363308..aa0b531 100644
--- a/src/Daemon/PluginManager.cpp
+++ b/src/Daemon/PluginManager.cpp
@@ -179,8 +179,7 @@ void CPluginManager::LoadPlugin(const std::string& pName)
catch (CABRTException& e)
{
delete abrtPlugin;
- warn_client("CPluginManager::LoadPlugin(): " + e.what());
- warn_client("Failed to load plugin " + pName);
+ warn_client(ssprintf("Failed to load plugin %s: %s", pName.c_str(), e.what()));
}
}
}
@@ -218,7 +217,7 @@ void CPluginManager::RegisterPlugin(const std::string& pName)
log("Can't initialize plugin %s(%s): %s",
pName.c_str(),
plugin_type_str[abrt_plugin->second->GetType()],
- e.what().c_str()
+ e.what()
);
UnLoadPlugin(pName);
return;
diff --git a/src/Hooks/CCpp.cpp b/src/Hooks/CCpp.cpp
index 4e0dc71..0f95d05 100644
--- a/src/Hooks/CCpp.cpp
+++ b/src/Hooks/CCpp.cpp
@@ -221,7 +221,7 @@ int main(int argc, char** argv)
}
catch (CABRTException& e)
{
- error_msg_and_die("%s", e.what().c_str());
+ error_msg_and_die("%s", e.what());
}
catch (std::exception& e)
{