Enhance exception throwing with Boost Exception library
Change-Id: I471023fc23ffaebe04d9668426b4c1b03e4962ba
Refs: #2997
diff --git a/src/util/regex/regex-backref-matcher.hpp b/src/util/regex/regex-backref-matcher.hpp
index 1174541..77efd83 100644
--- a/src/util/regex/regex-backref-matcher.hpp
+++ b/src/util/regex/regex-backref-matcher.hpp
@@ -69,7 +69,7 @@
RegexBackrefMatcher::compile()
{
if (m_expr.size() < 2)
- throw RegexMatcher::Error("Unrecognized format: " + m_expr);
+ BOOST_THROW_EXCEPTION(RegexMatcher::Error("Unrecognized format: " + m_expr));
size_t lastIndex = m_expr.size() - 1;
if ('(' == m_expr[0] && ')' == m_expr[lastIndex]) {
@@ -80,7 +80,7 @@
m_matchers.push_back(matcher);
}
else
- throw RegexMatcher::Error("Unrecognized format: " + m_expr);
+ BOOST_THROW_EXCEPTION(RegexMatcher::Error("Unrecognized format: " + m_expr));
}
diff --git a/src/util/regex/regex-component-matcher.hpp b/src/util/regex/regex-component-matcher.hpp
index 6b5474a..029bb03 100644
--- a/src/util/regex/regex-component-matcher.hpp
+++ b/src/util/regex/regex-component-matcher.hpp
@@ -136,7 +136,8 @@
}
else
{
- throw RegexMatcher::Error("Non-exact component search is not supported yet!");
+ BOOST_THROW_EXCEPTION(RegexMatcher::Error("Non-exact component search is not supported "
+ "yet"));
}
return false;
diff --git a/src/util/regex/regex-component-set-matcher.hpp b/src/util/regex/regex-component-set-matcher.hpp
index 9c2ff16..b20ad44 100644
--- a/src/util/regex/regex-component-set-matcher.hpp
+++ b/src/util/regex/regex-component-set-matcher.hpp
@@ -92,7 +92,8 @@
RegexComponentSetMatcher::compile()
{
if (m_expr.size() < 2)
- throw RegexMatcher::Error("Regexp compile error (cannot parse " + m_expr + ")");
+ BOOST_THROW_EXCEPTION(RegexMatcher::Error("Regexp compile error (cannot parse " +
+ m_expr + ")"));
switch (m_expr[0]) {
case '<':
@@ -101,7 +102,8 @@
{
size_t lastIndex = m_expr.size() - 1;
if (']' != m_expr[lastIndex])
- throw RegexMatcher::Error("Regexp compile error (no matching ']' in " + m_expr + ")");
+ BOOST_THROW_EXCEPTION(RegexMatcher::Error("Regexp compile error (no matching ']' in " +
+ m_expr + ")"));
if ('^' == m_expr[1]) {
m_isInclusion = false;
@@ -112,7 +114,8 @@
break;
}
default:
- throw RegexMatcher::Error("Regexp compile error (cannot parse " + m_expr + ")");
+ BOOST_THROW_EXCEPTION(RegexMatcher::Error("Regexp compile error (cannot parse " +
+ m_expr + ")"));
}
}
@@ -123,7 +126,7 @@
if (m_expr.size() != end)
{
- throw RegexMatcher::Error("Component expr error " + m_expr);
+ BOOST_THROW_EXCEPTION(RegexMatcher::Error("Component expr error " + m_expr));
}
else
{
@@ -142,7 +145,7 @@
while (index < lastIndex) {
if ('<' != m_expr[index])
- throw RegexMatcher::Error("Component expr error " + m_expr);
+ BOOST_THROW_EXCEPTION(RegexMatcher::Error("Component expr error " + m_expr));
tempIndex = index + 1;
index = extractComponent(tempIndex);
@@ -155,7 +158,7 @@
}
if (index != lastIndex)
- throw RegexMatcher::Error("Not sufficient expr to parse " + m_expr);
+ BOOST_THROW_EXCEPTION(RegexMatcher::Error("Not sufficient expr to parse " + m_expr));
}
inline bool
@@ -208,7 +211,7 @@
break;
case 0:
- throw RegexMatcher::Error("Error: square brackets mismatch");
+ BOOST_THROW_EXCEPTION(RegexMatcher::Error("Error: square brackets mismatch"));
break;
}
index++;
diff --git a/src/util/regex/regex-pattern-list-matcher.hpp b/src/util/regex/regex-pattern-list-matcher.hpp
index acca0f9..fedcbaa 100644
--- a/src/util/regex/regex-pattern-list-matcher.hpp
+++ b/src/util/regex/regex-pattern-list-matcher.hpp
@@ -86,7 +86,7 @@
subHead = index;
if (!extractPattern(subHead, &index))
- throw RegexMatcher::Error("Compile error");
+ BOOST_THROW_EXCEPTION(RegexMatcher::Error("Compile error"));
}
}
@@ -135,7 +135,7 @@
break;
default:
- throw RegexMatcher::Error("Unexpected syntax");
+ BOOST_THROW_EXCEPTION(RegexMatcher::Error("Unexpected syntax"));
}
*next = end;
@@ -152,7 +152,7 @@
while (lcount > rcount) {
if (index >= m_expr.size())
- throw RegexMatcher::Error("Parenthesis mismatch");
+ BOOST_THROW_EXCEPTION(RegexMatcher::Error("Parenthesis mismatch"));
if (left == m_expr[index])
lcount++;
@@ -184,7 +184,7 @@
break;
}
if (index == exprSize)
- throw RegexMatcher::Error("Missing right brace bracket");
+ BOOST_THROW_EXCEPTION(RegexMatcher::Error("Missing right brace bracket"));
else
return ++index;
}
diff --git a/src/util/regex/regex-repeat-matcher.hpp b/src/util/regex/regex-repeat-matcher.hpp
index 3d6e4f5..530721e 100644
--- a/src/util/regex/regex-repeat-matcher.hpp
+++ b/src/util/regex/regex-repeat-matcher.hpp
@@ -162,12 +162,12 @@
max = min;
}
else
- throw RegexMatcher::Error(std::string("Error: RegexRepeatMatcher.ParseRepetition(): ")
- + "Unrecognized format "+ m_expr);
+ BOOST_THROW_EXCEPTION(RegexMatcher::Error(std::string("Error: RegexRepeatMatcher.ParseRepetition():")
+ + " Unrecognized format "+ m_expr));
if (min > MAX_REPETITIONS || max > MAX_REPETITIONS || min > max)
- throw RegexMatcher::Error(std::string("Error: RegexRepeatMatcher.ParseRepetition(): ")
- + "Wrong number " + m_expr);
+ BOOST_THROW_EXCEPTION(RegexMatcher::Error(std::string("Error: RegexRepeatMatcher.ParseRepetition():")
+ + " Wrong number " + m_expr));
m_repeatMin = min;
m_repeatMax = max;
diff --git a/src/util/regex/regex-top-matcher.cpp b/src/util/regex/regex-top-matcher.cpp
index 5ed4937..30b755f 100644
--- a/src/util/regex/regex-top-matcher.cpp
+++ b/src/util/regex/regex-top-matcher.cpp
@@ -146,7 +146,7 @@
result.append(*it);
}
else
- throw RegexMatcher::Error("Exceed the range of back reference");
+ BOOST_THROW_EXCEPTION(RegexMatcher::Error("Exceed the range of back reference"));
}
}
return result;
@@ -161,23 +161,23 @@
{
offset++;
if (offset >= expand.size())
- throw RegexMatcher::Error("wrong format of expand string!");
+ BOOST_THROW_EXCEPTION(RegexMatcher::Error("wrong format of expand string!"));
while (expand[offset] <= '9' and expand[offset] >= '0') {
offset++;
if (offset > expand.size())
- throw RegexMatcher::Error("wrong format of expand string!");
+ BOOST_THROW_EXCEPTION(RegexMatcher::Error("wrong format of expand string!"));
}
if (offset > begin + 1)
return expand.substr(begin, offset - begin);
else
- throw RegexMatcher::Error("wrong format of expand string!");
+ BOOST_THROW_EXCEPTION(RegexMatcher::Error("wrong format of expand string!"));
}
else if (expand[offset] == '<')
{
offset++;
if (offset >= expand.size())
- throw RegexMatcher::Error("wrong format of expand string!");
+ BOOST_THROW_EXCEPTION(RegexMatcher::Error("wrong format of expand string!"));
size_t left = 1;
size_t right = 0;
@@ -189,12 +189,12 @@
right++;
offset++;
if (offset >= expand.size())
- throw RegexMatcher::Error("wrong format of expand string!");
+ BOOST_THROW_EXCEPTION(RegexMatcher::Error("wrong format of expand string!"));
}
return expand.substr(begin, offset - begin);
}
else
- throw RegexMatcher::Error("wrong format of expand string!");
+ BOOST_THROW_EXCEPTION(RegexMatcher::Error("wrong format of expand string!"));
}
shared_ptr<RegexTopMatcher>