Enhance exception throwing with Boost Exception library
Change-Id: I471023fc23ffaebe04d9668426b4c1b03e4962ba
Refs: #2997
diff --git a/src/interest.cpp b/src/interest.cpp
index 4873f39..d4ce90b 100644
--- a/src/interest.cpp
+++ b/src/interest.cpp
@@ -306,7 +306,7 @@
// SelectedDelegation?
if (m_wire.type() != tlv::Interest)
- throw Error("Unexpected TLV number when decoding Interest");
+ BOOST_THROW_EXCEPTION(Error("Unexpected TLV number when decoding Interest"));
// Name
m_name.wireDecode(m_wire.get(tlv::Name));
@@ -345,14 +345,14 @@
val = m_wire.find(tlv::SelectedDelegation);
if (val != m_wire.elements_end()) {
if (!this->hasLink()) {
- throw Error("Interest contains selectedDelegation, but no LINK object");
+ BOOST_THROW_EXCEPTION(Error("Interest contains selectedDelegation, but no LINK object"));
}
uint64_t selectedDelegation = readNonNegativeInteger(*val);
if (selectedDelegation < uint64_t(Link::countDelegationsFromWire(m_link))) {
m_selectedDelegationIndex = static_cast<size_t>(selectedDelegation);
}
else {
- throw Error("Invalid selected delegation index when decoding Interest");
+ BOOST_THROW_EXCEPTION(Error("Invalid selected delegation index when decoding Interest"));
}
}
}
@@ -372,7 +372,7 @@
{
return Link(m_link);
}
- throw Error("There is no encapsulated link object");
+ BOOST_THROW_EXCEPTION(Error("There is no encapsulated link object"));
}
void
@@ -380,7 +380,7 @@
{
m_link = link;
if (!link.hasWire()) {
- throw Error("The given link does not have a wire format");
+ BOOST_THROW_EXCEPTION(Error("The given link does not have a wire format"));
}
m_wire.reset();
this->unsetSelectedDelegation();
@@ -408,7 +408,7 @@
Interest::getSelectedDelegation() const
{
if (!hasSelectedDelegation()) {
- throw Error("There is no encapsulated selected delegation");
+ BOOST_THROW_EXCEPTION(Error("There is no encapsulated selected delegation"));
}
return std::get<1>(Link::getDelegationFromWire(m_link, m_selectedDelegationIndex));
}
@@ -421,7 +421,7 @@
m_selectedDelegationIndex = delegationIndex;
}
else {
- throw std::invalid_argument("Invalid selected delegation name");
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid selected delegation name"));
}
m_wire.reset();
}
@@ -430,7 +430,7 @@
Interest::setSelectedDelegation(size_t delegationIndex)
{
if (delegationIndex >= Link(m_link).getDelegations().size()) {
- throw Error("Invalid selected delegation index");
+ BOOST_THROW_EXCEPTION(Error("Invalid selected delegation index"));
}
m_selectedDelegationIndex = delegationIndex;
m_wire.reset();