Enhance exception throwing with Boost Exception library
Change-Id: I471023fc23ffaebe04d9668426b4c1b03e4962ba
Refs: #2997
diff --git a/src/security/conf/key-locator-checker.hpp b/src/security/conf/key-locator-checker.hpp
index 7d5bb9c..667dfeb 100644
--- a/src/security/conf/key-locator-checker.hpp
+++ b/src/security/conf/key-locator-checker.hpp
@@ -234,14 +234,14 @@
// Get checker.key-locator.type
if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "type"))
- throw Error("Expect <checker.key-locator.type>!");
+ BOOST_THROW_EXCEPTION(Error("Expect <checker.key-locator.type>!"));
std::string type = propertyIt->second.data();
if (boost::iequals(type, "name"))
return createKeyLocatorNameChecker(configSection, filename);
else
- throw Error("Unsupported checker.key-locator.type: " + type);
+ BOOST_THROW_EXCEPTION(Error("Unsupported checker.key-locator.type: " + type));
}
private:
@@ -253,7 +253,7 @@
propertyIt++;
if (propertyIt == configSection.end())
- throw Error("Expect more checker.key-locator properties");
+ BOOST_THROW_EXCEPTION(Error("Expect more checker.key-locator properties"));
if (boost::iequals(propertyIt->first, "name"))
{
@@ -264,13 +264,13 @@
}
catch (Name::Error& e)
{
- throw Error("Invalid checker.key-locator.name: " +
- propertyIt->second.data());
+ BOOST_THROW_EXCEPTION(Error("Invalid checker.key-locator.name: " +
+ propertyIt->second.data()));
}
propertyIt++;
if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "relation"))
- throw Error("Expect <checker.key-locator.relation>!");
+ BOOST_THROW_EXCEPTION(Error("Expect <checker.key-locator.relation>!"));
std::string relationString = propertyIt->second.data();
propertyIt++;
@@ -283,10 +283,10 @@
else if (boost::iequals(relationString, "is-strict-prefix-of"))
relation = KeyLocatorChecker::RELATION_IS_STRICT_PREFIX_OF;
else
- throw Error("Unsupported relation: " + relationString);
+ BOOST_THROW_EXCEPTION(Error("Unsupported relation: " + relationString));
if (propertyIt != configSection.end())
- throw Error("Expect the end of checker.key-locator!");
+ BOOST_THROW_EXCEPTION(Error("Expect the end of checker.key-locator!"));
return shared_ptr<RelationKeyLocatorNameChecker>
(new RelationKeyLocatorNameChecker(name, relation));
@@ -297,7 +297,7 @@
propertyIt++;
if (propertyIt != configSection.end())
- throw Error("Expect the end of checker.key-locator!");
+ BOOST_THROW_EXCEPTION(Error("Expect the end of checker.key-locator!"));
try
{
@@ -306,7 +306,7 @@
}
catch (Regex::Error& e)
{
- throw Error("Invalid checker.key-locator.regex: " + regexString);
+ BOOST_THROW_EXCEPTION(Error("Invalid checker.key-locator.regex: " + regexString));
}
}
else if (boost::iequals(propertyIt->first, "hyper-relation"))
@@ -317,41 +317,41 @@
// Get k-regex
if (hPropertyIt == hSection.end() || !boost::iequals(hPropertyIt->first, "k-regex"))
- throw Error("Expect <checker.key-locator.hyper-relation.k-regex>!");
+ BOOST_THROW_EXCEPTION(Error("Expect <checker.key-locator.hyper-relation.k-regex>!"));
std::string kRegex = hPropertyIt->second.data();
hPropertyIt++;
// Get k-expand
if (hPropertyIt == hSection.end() || !boost::iequals(hPropertyIt->first, "k-expand"))
- throw Error("Expect <checker.key-locator.hyper-relation.k-expand>!");
+ BOOST_THROW_EXCEPTION(Error("Expect <checker.key-locator.hyper-relation.k-expand>!"));
std::string kExpand = hPropertyIt->second.data();
hPropertyIt++;
// Get h-relation
if (hPropertyIt == hSection.end() || !boost::iequals(hPropertyIt->first, "h-relation"))
- throw Error("Expect <checker.key-locator.hyper-relation.h-relation>!");
+ BOOST_THROW_EXCEPTION(Error("Expect <checker.key-locator.hyper-relation.h-relation>!"));
std::string hRelation = hPropertyIt->second.data();
hPropertyIt++;
// Get p-regex
if (hPropertyIt == hSection.end() || !boost::iequals(hPropertyIt->first, "p-regex"))
- throw Error("Expect <checker.key-locator.hyper-relation.p-regex>!");
+ BOOST_THROW_EXCEPTION(Error("Expect <checker.key-locator.hyper-relation.p-regex>!"));
std::string pRegex = hPropertyIt->second.data();
hPropertyIt++;
// Get p-expand
if (hPropertyIt == hSection.end() || !boost::iequals(hPropertyIt->first, "p-expand"))
- throw Error("Expect <checker.key-locator.hyper-relation.p-expand>!");
+ BOOST_THROW_EXCEPTION(Error("Expect <checker.key-locator.hyper-relation.p-expand>!"));
std::string pExpand = hPropertyIt->second.data();
hPropertyIt++;
if (hPropertyIt != hSection.end())
- throw Error("Expect the end of checker.key-locator.hyper-relation!");
+ BOOST_THROW_EXCEPTION(Error("Expect the end of checker.key-locator.hyper-relation!"));
KeyLocatorChecker::Relation relation;
if (boost::iequals(hRelation, "equal"))
@@ -361,7 +361,8 @@
else if (boost::iequals(hRelation, "is-strict-prefix-of"))
relation = KeyLocatorChecker::RELATION_IS_STRICT_PREFIX_OF;
else
- throw Error("Unsupported checker.key-locator.hyper-relation.h-relation: " + hRelation);
+ BOOST_THROW_EXCEPTION(Error("Unsupported checker.key-locator.hyper-relation.h-relation: "
+ + hRelation));
try
{
@@ -372,11 +373,11 @@
}
catch (Regex::Error& e)
{
- throw Error("Invalid regex for key-locator.hyper-relation");
+ BOOST_THROW_EXCEPTION(Error("Invalid regex for key-locator.hyper-relation"));
}
}
else
- throw Error("Unsupported checker.key-locator");
+ BOOST_THROW_EXCEPTION(Error("Unsupported checker.key-locator"));
}
};