diff options
| author | Zdenek Prikryl <zdeny@dhcp-lab-218.englab.brq.redhat.com> | 2009-04-23 16:10:55 +0200 |
|---|---|---|
| committer | Zdenek Prikryl <zdeny@dhcp-lab-218.englab.brq.redhat.com> | 2009-04-23 16:10:55 +0200 |
| commit | 7b2d4874b7bd992ef3f09124b7ebbc346eba01f4 (patch) | |
| tree | 82d62057cf9cae9b4a1fca46f9f30693d92a3f6e /lib/Plugins | |
| parent | 4fa35669bd72794b1acae57c98e57297d9e65794 (diff) | |
| download | abrt-7b2d4874b7bd992ef3f09124b7ebbc346eba01f4.tar.gz abrt-7b2d4874b7bd992ef3f09124b7ebbc346eba01f4.tar.xz abrt-7b2d4874b7bd992ef3f09124b7ebbc346eba01f4.zip | |
added new abrt exceptions
Diffstat (limited to 'lib/Plugins')
| -rw-r--r-- | lib/Plugins/Bugzilla.cpp | 16 | ||||
| -rw-r--r-- | lib/Plugins/CCpp.cpp | 17 | ||||
| -rw-r--r-- | lib/Plugins/Kerneloops.cpp | 9 | ||||
| -rw-r--r-- | lib/Plugins/Logger.cpp | 4 | ||||
| -rw-r--r-- | lib/Plugins/Mailx.cpp | 9 | ||||
| -rw-r--r-- | lib/Plugins/RunApp.cpp | 3 | ||||
| -rw-r--r-- | lib/Plugins/SQLite3.cpp | 14 |
7 files changed, 39 insertions, 33 deletions
diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp index e43bc85..ed9e02c 100644 --- a/lib/Plugins/Bugzilla.cpp +++ b/lib/Plugins/Bugzilla.cpp @@ -3,6 +3,7 @@ #include "CrashTypes.h" #include "PluginSettings.h" #include "DebugDump.h" +#include "ABRTException.h" #include <iostream> CReporterBugzilla::CReporterBugzilla() : @@ -17,6 +18,7 @@ CReporterBugzilla::~CReporterBugzilla() { delete m_pXmlrpcTransport; delete m_pXmlrpcClient; + delete m_pCarriageParm; } void CReporterBugzilla::Login() @@ -36,7 +38,7 @@ void CReporterBugzilla::Login() } catch (std::exception& e) { - throw std::string(e.what()); + throw CABRTException(EXCEP_PLUGIN, std::string("CReporterBugzilla::Login(): ") + e.what()); } } @@ -51,7 +53,7 @@ void CReporterBugzilla::Logout() } catch (std::exception& e) { - throw std::string(e.what()); + throw CABRTException(EXCEP_PLUGIN, std::string("CReporterBugzilla::Logout(): ") + e.what()); } } @@ -70,7 +72,7 @@ bool CReporterBugzilla::CheckUUIDInBugzilla(const std::string& pComponent, const } catch (std::exception& e) { - throw std::string(e.what()); + throw CABRTException(EXCEP_PLUGIN, std::string("CReporterBugzilla::CheckUUIDInBugzilla(): ") + e.what()); } ret = xmlrpc_c::value_struct(rpc->getResult()); std::vector<xmlrpc_c::value> bugs = xmlrpc_c::value_array(ret["bugs"]).vectorValueValue(); @@ -96,7 +98,7 @@ void CReporterBugzilla::CreateNewBugDescription(const map_crash_report_t& pCrash { if (it->second[CD_TYPE] == CD_TXT || it->second[CD_TYPE] == CD_ATT) { - if (it->first != FILENAME_UUID && + if (it->first != CD_UUID && it->first != FILENAME_ARCHITECTURE && it->first != FILENAME_RELEASE && it->first != CD_REPRODUCE && @@ -144,7 +146,7 @@ void CReporterBugzilla::NewBug(const map_crash_report_t& pCrashReport) bugParams["version"] = xmlrpc_c::value_string(version); bugParams["summary"] = xmlrpc_c::value_string("[abrt] crash detected in " + component); bugParams["description"] = xmlrpc_c::value_string(description); - bugParams["status_whiteboard"] = xmlrpc_c::value_string("abrt_hash:" + pCrashReport.find(FILENAME_UUID)->second[CD_CONTENT]); + bugParams["status_whiteboard"] = xmlrpc_c::value_string("abrt_hash:" + pCrashReport.find(CD_UUID)->second[CD_CONTENT]); bugParams["platform"] = xmlrpc_c::value_string(pCrashReport.find(FILENAME_ARCHITECTURE)->second[CD_CONTENT]); paramList.add(xmlrpc_c::value_struct(bugParams)); @@ -157,7 +159,7 @@ void CReporterBugzilla::NewBug(const map_crash_report_t& pCrashReport) } catch (std::exception& e) { - throw std::string(e.what()); + throw CABRTException(EXCEP_PLUGIN, std::string("CReporterBugzilla::NewBug(): ") + e.what()); } } @@ -166,7 +168,7 @@ void CReporterBugzilla::Report(const map_crash_report_t& pCrashReport, const std { std::string package = pCrashReport.find(FILENAME_PACKAGE)->second[CD_CONTENT]; std::string component = package.substr(0, package.rfind("-", package.rfind("-")-1)); - std::string uuid = pCrashReport.find(FILENAME_UUID)->second[CD_CONTENT]; + std::string uuid = pCrashReport.find(CD_UUID)->second[CD_CONTENT]; Login(); if (!CheckUUIDInBugzilla(component, uuid)) { diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index 76571f3..286f730 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -20,9 +20,10 @@ */ #include "CCpp.h" -#include <fstream> +#include "ABRTException.h" #include "DebugDump.h" #include "PluginSettings.h" +#include <fstream> #include <sstream> #include <iostream> #include <ctype.h> @@ -70,7 +71,7 @@ std::string CAnalyzerCCpp::CreateHash(const std::string& pInput) hc = HASH_Create(HASH_AlgSHA1); if (!hc) { - throw std::string("CAnalyzerCCpp::CreateHash(): cannot initialize hash."); + throw CABRTException(EXCEP_PLUGIN, "CAnalyzerCCpp::CreateHash(): cannot initialize hash."); } HASH_Begin(hc); HASH_Update(hc, reinterpret_cast<const unsigned char*>(pInput.c_str()), pInput.length()); @@ -104,7 +105,7 @@ void CAnalyzerCCpp::InstallDebugInfos(const std::string& pPackage) m_Pid = child; if (child < 0) { - throw std::string("CAnalyzerCCpp::RunGdb(): fork failed."); + throw CABRTException(EXCEP_PLUGIN, "CAnalyzerCCpp::RunGdb(): fork failed."); } if (child == 0) { @@ -164,7 +165,7 @@ void CAnalyzerCCpp::InstallDebugInfos(const std::string& pPackage) close(pipeout[0]); kill(child, SIGTERM); wait(NULL); - throw std::string("CAnalyzerCCpp::InstallDebugInfos(): cannot install debuginfos for ") + pPackage; + throw CABRTException(EXCEP_PLUGIN, "CAnalyzerCCpp::InstallDebugInfos(): cannot install debuginfos for " + pPackage); } if (strstr(buff, "Total download size") != NULL) { @@ -175,7 +176,7 @@ void CAnalyzerCCpp::InstallDebugInfos(const std::string& pPackage) close(pipeout[0]); kill(child, SIGTERM); wait(NULL); - throw std::string("CAnalyzerCCpp::InstallDebugInfos(): cannot install debuginfos for ") + pPackage; + throw CABRTException(EXCEP_PLUGIN, "CAnalyzerCCpp::InstallDebugInfos(): cannot install debuginfos for " + pPackage); } } } @@ -211,7 +212,7 @@ void CAnalyzerCCpp::GetBacktrace(const std::string& pDebugDumpDir, std::string& } else { - throw "CAnalyzerCCpp::GetBacktrace(): cannot create gdb script " + tmpFile ; + throw CABRTException(EXCEP_PLUGIN, "CAnalyzerCCpp::GetBacktrace(): cannot create gdb script " + tmpFile); } char* command = (char*)"gdb"; char* args[5] = { (char*)"gdb", (char*)"-batch", (char*)"-x", NULL, NULL }; @@ -361,7 +362,7 @@ void CAnalyzerCCpp::ExecVP(const char* pCommand, char* const pArgs[], const std: m_Pid = child; if (child == -1) { - throw std::string("CAnalyzerCCpp::RunGdb(): fork failed."); + CABRTException(EXCEP_PLUGIN, "CAnalyzerCCpp::RunGdb(): fork failed."); } if(child == 0) { @@ -497,7 +498,7 @@ void CAnalyzerCCpp::Init() } if (NSS_NoDB_Init(NULL) != SECSuccess) { - throw std::string("CAnalyzerCCpp::CreateHash(): cannot initialize NSS library."); + throw CABRTException(EXCEP_PLUGIN, "CAnalyzerCCpp::CreateHash(): cannot initialize NSS library."); } } diff --git a/lib/Plugins/Kerneloops.cpp b/lib/Plugins/Kerneloops.cpp index 144fac8..179ba41 100644 --- a/lib/Plugins/Kerneloops.cpp +++ b/lib/Plugins/Kerneloops.cpp @@ -28,6 +28,7 @@ #include "KerneloopsSysLog.h" #include "DebugDump.h" #include "PluginSettings.h" +#include "ABRTException.h" #include <sstream> #include <assert.h> @@ -91,7 +92,7 @@ void CAnalyzerKerneloops::Report() time_t t = time(NULL); if (((time_t) -1) == t) { - throw std::string("CAnalyzerKerneloops::Report(): cannot get local time."); + throw CABRTException(EXCEP_PLUGIN, "CAnalyzerKerneloops::Report(): cannot get local time."); } m_pOopsList = m_pSysLog.GetOopsList(); @@ -114,9 +115,9 @@ void CAnalyzerKerneloops::Report() m_pDebugDump.SaveText(FILENAME_KERNELOOPS, m_pOops.m_sData); m_pDebugDump.Close(); } - catch (std::string sError) + catch (CABRTException& e) { - throw std::string("CAnalyzerKerneloops::Report(): ") + sError.c_str(); + throw CABRTException(EXCEP_PLUGIN, "CAnalyzerKerneloops::Report(): " + e.what()); } m_pOopsList.pop_back(); } @@ -127,7 +128,7 @@ void CAnalyzerKerneloops::Init() /* daemonize */ pid_t pid = fork(); if (pid < 0) - throw std::string("CAnalyzerKerneloops::Init(): fork failed."); + throw CABRTException(EXCEP_PLUGIN, "CAnalyzerKerneloops::Init(): fork failed."); /* hack: release Init() */ if (pid) diff --git a/lib/Plugins/Logger.cpp b/lib/Plugins/Logger.cpp index d340b2d..43c219f 100644 --- a/lib/Plugins/Logger.cpp +++ b/lib/Plugins/Logger.cpp @@ -55,7 +55,7 @@ void CLogger::Report(const map_crash_report_t& pCrashReport, const std::string& { if (it->second[CD_TYPE] == CD_TXT) { - if (it->first != FILENAME_UUID && + if (it->first != CD_UUID && it->first != FILENAME_ARCHITECTURE && it->first != FILENAME_KERNEL && it->first != FILENAME_PACKAGE) @@ -64,7 +64,7 @@ void CLogger::Report(const map_crash_report_t& pCrashReport, const std::string& additionalFiles << "-----" << std::endl; additionalFiles << it->second[CD_CONTENT] << std::endl << std::endl; } - else if (it->first == FILENAME_UUID) + else if (it->first == CD_UUID) { UUIDFile << it->first << std::endl; UUIDFile << "-----" << std::endl; diff --git a/lib/Plugins/Mailx.cpp b/lib/Plugins/Mailx.cpp index b7cdcfe..6a5cb59 100644 --- a/lib/Plugins/Mailx.cpp +++ b/lib/Plugins/Mailx.cpp @@ -23,6 +23,7 @@ #include <stdio.h> #include <sstream> #include "DebugDump.h" +#include "ABRTException.h" #include "PluginSettings.h" #define MAILX_COMMAND "/bin/mailx" @@ -48,11 +49,11 @@ void CMailx::SendEmail(const std::string& pSubject, const std::string& pText) command = popen(mailx_command.c_str(), "w"); if (!command) { - throw std::string("CMailx::SendEmail: Can not execute mailx."); + throw CABRTException(EXCEP_PLUGIN, "CMailx::SendEmail(): Can not execute mailx."); } if (fputs(pText.c_str(), command) == -1) { - throw std::string("CMailx::SendEmail: Can not send data."); + throw CABRTException(EXCEP_PLUGIN, "CMailx::SendEmail(): Can not send data."); } pclose(command); } @@ -68,7 +69,7 @@ void CMailx::Report(const map_crash_report_t& pCrashReport, const std::string& p { if (it->second[CD_TYPE] == CD_TXT) { - if (it->first != FILENAME_UUID && + if (it->first != CD_UUID && it->first != FILENAME_ARCHITECTURE && it->first != FILENAME_KERNEL && it->first != FILENAME_PACKAGE) @@ -77,7 +78,7 @@ void CMailx::Report(const map_crash_report_t& pCrashReport, const std::string& p additionalFiles << "-----" << std::endl; additionalFiles << it->second[CD_CONTENT] << std::endl << std::endl; } - else if (it->first == FILENAME_UUID) + else if (it->first == CD_UUID) { UUIDFile << it->first << std::endl; UUIDFile << "-----" << std::endl; diff --git a/lib/Plugins/RunApp.cpp b/lib/Plugins/RunApp.cpp index 9f08e05..8a8db08 100644 --- a/lib/Plugins/RunApp.cpp +++ b/lib/Plugins/RunApp.cpp @@ -23,6 +23,7 @@ #include "RunApp.h" #include <stdio.h> #include "DebugDump.h" +#include "ABRTException.h" #define COMMAND 0 #define FILENAME 1 @@ -67,7 +68,7 @@ void CActionRunApp::Run(const std::string& pDebugDumpDir, FILE *fp = popen(args[COMMAND].c_str(), "r"); if (fp == NULL) { - throw "CActionRunApp::Run(): cannot execute " + args[COMMAND]; + throw CABRTException(EXCEP_PLUGIN, "CActionRunApp::Run(): cannot execute " + args[COMMAND]); } while (fgets(line, 1024, fp) != NULL) { diff --git a/lib/Plugins/SQLite3.cpp b/lib/Plugins/SQLite3.cpp index 9a5c6e0..13a0ed6 100644 --- a/lib/Plugins/SQLite3.cpp +++ b/lib/Plugins/SQLite3.cpp @@ -25,7 +25,7 @@ #include <string> #include <iostream> #include "PluginSettings.h" - +#include "ABRTException.h" #define ABRT_TABLE "abrt" #define SQLITE3_MASTER_TABLE "sqlite_master" @@ -54,7 +54,7 @@ void CSQLite3::Exec(const std::string& pCommand) int ret = sqlite3_exec(m_pDB, pCommand.c_str(), 0, 0, &err); if (ret != SQLITE_OK) { - throw std::string("SQLite3::Exec(): Error on: " + pCommand + " " + err); + throw CABRTException(EXCEP_PLUGIN, "SQLite3::Exec(): Error on: " + pCommand + " " + err); } } @@ -66,7 +66,7 @@ void CSQLite3::GetTable(const std::string& pCommand, vector_database_rows_t& pTa int ret = sqlite3_get_table(m_pDB, pCommand.c_str(), &table, &nrow, &ncol, &err); if (ret != SQLITE_OK) { - throw std::string("SQLite3::GetTable(): Error on: " + pCommand + " " + err); + throw CABRTException(EXCEP_PLUGIN, "SQLite3::GetTable(): Error on: " + pCommand + " " + err); } pTable.clear(); int ii; @@ -122,7 +122,7 @@ bool CSQLite3::OpenDB() if (ret != SQLITE_OK && ret != SQLITE_CANTOPEN) { - throw std::string("SQLite3::CheckDB(): Could not open database. ") + sqlite3_errmsg(m_pDB); + throw CABRTException(EXCEP_PLUGIN, std::string("SQLite3::CheckDB(): Could not open database. ") + sqlite3_errmsg(m_pDB)); } return ret == SQLITE_OK; } @@ -135,7 +135,7 @@ void CSQLite3::CreateDB() NULL); if(ret != SQLITE_OK) { - throw std::string("SQLite3::Create(): Could not create database. ") + sqlite3_errmsg(m_pDB); + throw CABRTException(EXCEP_PLUGIN, std::string("SQLite3::Create(): Could not create database. ") + sqlite3_errmsg(m_pDB)); } } @@ -208,7 +208,7 @@ void CSQLite3::Delete(const std::string& pUUID, const std::string& pUID) } else { - throw std::string("CSQLite3::Delete(): UUID is not found in DB."); + throw CABRTException(EXCEP_PLUGIN, "CSQLite3::Delete(): UUID is not found in DB."); } } @@ -223,7 +223,7 @@ void CSQLite3::SetReported(const std::string& pUUID, const std::string& pUID) } else { - throw std::string("CSQLite3::SetReported(): UUID is not found in DB."); + throw CABRTException(EXCEP_PLUGIN, "CSQLite3::SetReported(): UUID is not found in DB."); } } |
