Enhance exception throwing with Boost Exception library
Change-Id: I471023fc23ffaebe04d9668426b4c1b03e4919aa
Refs: #2541
diff --git a/core/config-file.cpp b/core/config-file.cpp
index a6861e3..9724168 100644
--- a/core/config-file.cpp
+++ b/core/config-file.cpp
@@ -40,7 +40,7 @@
msg += filename;
msg += ": no module subscribed for section \"" + sectionName + "\"";
- throw ConfigFile::Error(msg);
+ BOOST_THROW_EXCEPTION(ConfigFile::Error(msg));
}
void
@@ -73,7 +73,7 @@
{
std::string msg = "Failed to read configuration file: ";
msg += filename;
- throw Error(msg);
+ BOOST_THROW_EXCEPTION(Error(msg));
}
parse(inputFile, isDryRun, filename);
inputFile.close();
@@ -100,7 +100,7 @@
msg << "Failed to parse configuration file";
msg << " " << filename;
msg << " " << error.message() << " line " << error.line();
- throw Error(msg.str());
+ BOOST_THROW_EXCEPTION(Error(msg.str()));
}
process(isDryRun, filename);
@@ -124,7 +124,7 @@
std::string msg = "Error processing configuration file: ";
msg += filename;
msg += " no data";
- throw Error(msg);
+ BOOST_THROW_EXCEPTION(Error(msg));
}
for (ConfigSection::const_iterator i = m_global.begin(); i != m_global.end(); ++i)
diff --git a/core/logger-factory.cpp b/core/logger-factory.cpp
index 20578c3..a463b94 100644
--- a/core/logger-factory.cpp
+++ b/core/logger-factory.cpp
@@ -87,7 +87,7 @@
catch (const boost::bad_lexical_cast& error) {
}
- throw LoggerFactory::Error("Unsupported logging level \"" + level + "\"");
+ BOOST_THROW_EXCEPTION(LoggerFactory::Error("Unsupported logging level \"" + level + "\""));
}
LogLevel
@@ -101,7 +101,7 @@
}
if (levelString.empty()) {
- throw LoggerFactory::Error("No logging level found for option \"" + key + "\"");
+ BOOST_THROW_EXCEPTION(LoggerFactory::Error("No logging level found for option \"" + key + "\""));
}
return parseLevel(levelString);
diff --git a/core/network-interface.cpp b/core/network-interface.cpp
index 048b37e..02761a9 100644
--- a/core/network-interface.cpp
+++ b/core/network-interface.cpp
@@ -86,7 +86,8 @@
ifaddrs* ifa_list = nullptr;
if (::getifaddrs(&ifa_list) < 0)
- throw std::runtime_error(std::string("getifaddrs() failed: ") + strerror(errno));
+ BOOST_THROW_EXCEPTION(std::runtime_error(std::string("getifaddrs() failed: ") +
+ strerror(errno)));
for (ifaddrs* ifa = ifa_list; ifa != nullptr; ifa = ifa->ifa_next) {
std::string ifname(ifa->ifa_name);
diff --git a/core/privilege-helper.hpp b/core/privilege-helper.hpp
index 380dc64..984532f 100644
--- a/core/privilege-helper.hpp
+++ b/core/privilege-helper.hpp
@@ -36,8 +36,10 @@
{
public:
- /// \brief PrivilegeHelper::Error represents a serious seteuid/gid failure and
- /// should only be caught by main in as part of a graceful program termination.
+ /** \brief represents a serious seteuid/gid failure
+ * \detail This should only be caught by main in as part of a graceful program termination.
+ * \note This is not an std::exception and BOOST_THROW_EXCEPTION should not be used.
+ */
class Error
{
public: