Enhance exception throwing with Boost Exception library
Change-Id: I471023fc23ffaebe04d9668426b4c1b03e4962ba
Refs: #2997
diff --git a/docs/code-style.rst b/docs/code-style.rst
index 58bd4b0..6a578ba 100644
--- a/docs/code-style.rst
+++ b/docs/code-style.rst
@@ -1113,3 +1113,9 @@
``NDN_CXX_DECL_OVERRIDE`` and ``NDN_CXX_DECL_FINAL`` macros are for ndn-cxx internal use.
Other projects, if adopting this style guide, should define their own macros if needed.
+
+3.31. The recommended way to throw an exception derived from ``std::exception`` is to use
+the ``BOOST_THROW_EXCEPTION``
+`macro <http://www.boost.org/doc/libs/1_42_0/libs/exception/doc/BOOST_THROW_EXCEPTION.html>`__.
+Exceptions thrown using this macro will be bundled with additional diagnostic information, including
+filename, line number, and function name from where the exception was thrown.
diff --git a/src/common.hpp b/src/common.hpp
index a4f61e3..123fb8a 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -131,6 +131,7 @@
#include <boost/assert.hpp>
#include <boost/concept_check.hpp>
#include <boost/noncopyable.hpp>
+#include <boost/throw_exception.hpp>
namespace ndn {
using boost::noncopyable;
diff --git a/src/data.cpp b/src/data.cpp
index 9e5effe..f96fb8f 100644
--- a/src/data.cpp
+++ b/src/data.cpp
@@ -63,7 +63,7 @@
if (!unsignedPortion && !m_signature)
{
- throw Error("Requested wire format, but data packet has not been signed yet");
+ BOOST_THROW_EXCEPTION(Error("Requested wire format, but data packet has not been signed yet"));
}
if (!unsignedPortion)
@@ -180,8 +180,8 @@
{
if (m_fullName.empty()) {
if (!m_wire.hasWire()) {
- throw Error("Full name requested, but Data packet does not have wire format "
- "(e.g., not signed)");
+ BOOST_THROW_EXCEPTION(Error("Full name requested, but Data packet does not have wire format "
+ "(e.g., not signed)"));
}
m_fullName = m_name;
m_fullName.appendImplicitSha256Digest(crypto::sha256(m_wire.wire(), m_wire.size()));
diff --git a/src/encoding/block.cpp b/src/encoding/block.cpp
index 77be4f2..624439d 100644
--- a/src/encoding/block.cpp
+++ b/src/encoding/block.cpp
@@ -63,7 +63,7 @@
uint64_t length = tlv::readVarNumber(m_value_begin, m_value_end);
if (length != static_cast<uint64_t>(m_value_end - m_value_begin))
{
- throw tlv::Error("TLV length doesn't match buffer length");
+ BOOST_THROW_EXCEPTION(tlv::Error("TLV length doesn't match buffer length"));
}
}
@@ -95,7 +95,7 @@
uint64_t length = tlv::readVarNumber(m_value_begin, m_value_end);
if (length != static_cast<uint64_t>(m_value_end - m_value_begin))
{
- throw tlv::Error("TLV length doesn't match buffer length");
+ BOOST_THROW_EXCEPTION(tlv::Error("TLV length doesn't match buffer length"));
}
}
@@ -116,7 +116,7 @@
{
if (length != static_cast<uint64_t>(m_value_end - m_value_begin))
{
- throw tlv::Error("TLV length doesn't match buffer length");
+ BOOST_THROW_EXCEPTION(tlv::Error("TLV length doesn't match buffer length"));
}
}
}
@@ -131,7 +131,7 @@
if (length > static_cast<uint64_t>(tmp_end - tmp_begin))
{
- throw tlv::Error("Not enough data in the buffer to fully parse TLV");
+ BOOST_THROW_EXCEPTION(tlv::Error("Not enough data in the buffer to fully parse TLV"));
}
m_buffer = make_shared<Buffer>(buffer, (tmp_begin - buffer) + length);
@@ -156,7 +156,7 @@
if (length > static_cast<uint64_t>(tmp_end - tmp_begin))
{
- throw tlv::Error("Not enough data in the buffer to fully parse TLV");
+ BOOST_THROW_EXCEPTION(tlv::Error("Not enough data in the buffer to fully parse TLV"));
}
m_buffer = make_shared<Buffer>(buffer, (tmp_begin - buffer) + length);
@@ -210,7 +210,7 @@
}
if (length > MAX_SIZE_OF_BLOCK_FROM_STREAM)
- throw tlv::Error("Length of block from stream is too large");
+ BOOST_THROW_EXCEPTION(tlv::Error("Length of block from stream is too large"));
// We may still have some problem here, if some exception happens,
// we may completely lose all the bytes extracted from the stream.
@@ -220,7 +220,7 @@
is.read(buf + 1, length - 1);
if (length != static_cast<uint64_t>(is.gcount()) + 1) {
- throw tlv::Error("Not enough data in the buffer to fully parse TLV");
+ BOOST_THROW_EXCEPTION(tlv::Error("Not enough data in the buffer to fully parse TLV"));
}
return makeBinaryBlock(type, buf, length);
@@ -314,7 +314,7 @@
if (length > static_cast<uint64_t>(end - begin))
{
m_subBlocks.clear();
- throw tlv::Error("TLV length exceeds buffer length");
+ BOOST_THROW_EXCEPTION(tlv::Error("TLV length exceeds buffer length"));
}
Buffer::const_iterator element_end = begin + length;
@@ -364,7 +364,7 @@
os.write(reinterpret_cast<const char*>(i->value()), i->value_size());
}
else
- throw Error("Underlying value buffer is empty");
+ BOOST_THROW_EXCEPTION(Error("Underlying value buffer is empty"));
}
}
@@ -389,8 +389,8 @@
if (it != m_subBlocks.end())
return *it;
- throw Error("(Block::get) Requested a non-existed type [" +
- boost::lexical_cast<std::string>(type) + "] from Block");
+ BOOST_THROW_EXCEPTION(Error("(Block::get) Requested a non-existed type [" +
+ boost::lexical_cast<std::string>(type) + "] from Block"));
}
Block::element_const_iterator
@@ -414,7 +414,7 @@
Block::blockFromValue() const
{
if (value_size() == 0)
- throw Error("Underlying value buffer is empty");
+ BOOST_THROW_EXCEPTION(Error("Underlying value buffer is empty"));
Buffer::const_iterator begin = value_begin(),
end = value_end();
@@ -425,7 +425,7 @@
uint64_t length = tlv::readVarNumber(begin, end);
if (length != static_cast<uint64_t>(end - begin))
- throw tlv::Error("TLV length mismatches buffer length");
+ BOOST_THROW_EXCEPTION(tlv::Error("TLV length mismatches buffer length"));
return Block(m_buffer,
type,
@@ -454,7 +454,7 @@
Block::begin() const
{
if (!hasWire())
- throw Error("Underlying wire buffer is empty");
+ BOOST_THROW_EXCEPTION(Error("Underlying wire buffer is empty"));
return m_begin;
}
@@ -463,7 +463,7 @@
Block::end() const
{
if (!hasWire())
- throw Error("Underlying wire buffer is empty");
+ BOOST_THROW_EXCEPTION(Error("Underlying wire buffer is empty"));
return m_end;
}
@@ -472,7 +472,7 @@
Block::wire() const
{
if (!hasWire())
- throw Error("(Block::wire) Underlying wire buffer is empty");
+ BOOST_THROW_EXCEPTION(Error("(Block::wire) Underlying wire buffer is empty"));
return &*m_begin;
}
@@ -484,7 +484,7 @@
return m_size;
}
else
- throw Error("Block size cannot be determined (undefined block size)");
+ BOOST_THROW_EXCEPTION(Error("Block size cannot be determined (undefined block size)"));
}
bool
diff --git a/src/encoding/tlv.hpp b/src/encoding/tlv.hpp
index 7d7461f..b1223e8 100644
--- a/src/encoding/tlv.hpp
+++ b/src/encoding/tlv.hpp
@@ -303,12 +303,12 @@
readVarNumber(InputIterator& begin, const InputIterator& end)
{
if (begin == end)
- throw Error("Empty buffer during TLV processing");
+ BOOST_THROW_EXCEPTION(Error("Empty buffer during TLV processing"));
uint64_t value;
bool isOk = readVarNumber(begin, end, value);
if (!isOk)
- throw Error("Insufficient data during TLV processing");
+ BOOST_THROW_EXCEPTION(Error("Insufficient data during TLV processing"));
return value;
}
@@ -378,7 +378,7 @@
uint64_t type = readVarNumber(begin, end);
if (type > std::numeric_limits<uint32_t>::max())
{
- throw Error("TLV type code exceeds allowed maximum");
+ BOOST_THROW_EXCEPTION(Error("TLV type code exceeds allowed maximum"));
}
return static_cast<uint32_t>(type);
@@ -436,7 +436,7 @@
case 1:
{
if (end - begin < 1)
- throw Error("Insufficient data during TLV processing");
+ BOOST_THROW_EXCEPTION(Error("Insufficient data during TLV processing"));
uint8_t value = *begin;
begin++;
@@ -445,7 +445,7 @@
case 2:
{
if (end - begin < 2)
- throw Error("Insufficient data during TLV processing");
+ BOOST_THROW_EXCEPTION(Error("Insufficient data during TLV processing"));
uint16_t value = *reinterpret_cast<const uint16_t*>(&*begin);
begin += 2;
@@ -454,7 +454,7 @@
case 4:
{
if (end - begin < 4)
- throw Error("Insufficient data during TLV processing");
+ BOOST_THROW_EXCEPTION(Error("Insufficient data during TLV processing"));
uint32_t value = *reinterpret_cast<const uint32_t*>(&*begin);
begin += 4;
@@ -463,14 +463,14 @@
case 8:
{
if (end - begin < 8)
- throw Error("Insufficient data during TLV processing");
+ BOOST_THROW_EXCEPTION(Error("Insufficient data during TLV processing"));
uint64_t value = *reinterpret_cast<const uint64_t*>(&*begin);
begin += 8;
return be64toh(value);
}
}
- throw Error("Invalid length for nonNegativeInteger (only 1, 2, 4, and 8 are allowed)");
+ BOOST_THROW_EXCEPTION(Error("Invalid length for nonNegativeInteger (only 1, 2, 4, and 8 are allowed)"));
}
template<>
@@ -483,7 +483,7 @@
case 1:
{
if (begin == end)
- throw Error("Insufficient data during TLV processing");
+ BOOST_THROW_EXCEPTION(Error("Insufficient data during TLV processing"));
uint64_t value = *begin;
begin++;
@@ -500,7 +500,7 @@
}
if (count != 2)
- throw Error("Insufficient data during TLV processing");
+ BOOST_THROW_EXCEPTION(Error("Insufficient data during TLV processing"));
return value;
}
@@ -515,7 +515,7 @@
}
if (count != 4)
- throw Error("Insufficient data during TLV processing");
+ BOOST_THROW_EXCEPTION(Error("Insufficient data during TLV processing"));
return value;
}
@@ -530,12 +530,12 @@
}
if (count != 8)
- throw Error("Insufficient data during TLV processing");
+ BOOST_THROW_EXCEPTION(Error("Insufficient data during TLV processing"));
return value;
}
}
- throw Error("Invalid length for nonNegativeInteger (only 1, 2, 4, and 8 are allowed)");
+ BOOST_THROW_EXCEPTION(Error("Invalid length for nonNegativeInteger (only 1, 2, 4, and 8 are allowed)"));
}
inline size_t
diff --git a/src/exclude.cpp b/src/exclude.cpp
index b5482cd..bd4d4d7 100644
--- a/src/exclude.cpp
+++ b/src/exclude.cpp
@@ -49,7 +49,7 @@
Exclude::wireEncode(EncodingImpl<TAG>& encoder) const
{
if (m_exclude.empty()) {
- throw Error("Exclude filter cannot be empty");
+ BOOST_THROW_EXCEPTION(Error("Exclude filter cannot be empty"));
}
size_t totalLength = 0;
@@ -99,13 +99,13 @@
clear();
if (wire.type() != tlv::Exclude)
- throw tlv::Error("Unexpected TLV type when decoding Exclude");
+ BOOST_THROW_EXCEPTION(tlv::Error("Unexpected TLV type when decoding Exclude"));
m_wire = wire;
m_wire.parse();
if (m_wire.elements_size() == 0) {
- throw Error("Exclude element cannot be empty");
+ BOOST_THROW_EXCEPTION(Error("Exclude element cannot be empty"));
}
// Exclude ::= EXCLUDE-TYPE TLV-LENGTH Any? (NameComponent (Any)?)+
@@ -123,7 +123,7 @@
excludedComponent = std::move(name::Component(*i));
}
catch (const name::Component::Error&) {
- throw Error("Incorrect format of Exclude filter");
+ BOOST_THROW_EXCEPTION(Error("Incorrect format of Exclude filter"));
}
++i;
@@ -209,8 +209,8 @@
Exclude::excludeRange(const name::Component& from, const name::Component& to)
{
if (from >= to) {
- throw Error("Invalid exclude range [" + from.toUri() + ", " + to.toUri() + "] "
- "(for single name exclude use Exclude::excludeOne)");
+ BOOST_THROW_EXCEPTION(Error("Invalid exclude range [" + from.toUri() + ", " + to.toUri() + "] "
+ "(for single name exclude use Exclude::excludeOne)"));
}
iterator newFrom = m_exclude.lower_bound(from);
diff --git a/src/face.cpp b/src/face.cpp
index 7f3880a..98581b3 100644
--- a/src/face.cpp
+++ b/src/face.cpp
@@ -105,7 +105,7 @@
uri.reset(new util::FaceUri(*transportType));
}
catch (const util::FaceUri::Error& error) {
- throw ConfigFile::Error(error.what());
+ BOOST_THROW_EXCEPTION(ConfigFile::Error(error.what()));
}
const std::string protocol = uri->getScheme();
@@ -117,7 +117,7 @@
construct(TcpTransport::create(config), keyChain);
}
else {
- throw ConfigFile::Error("Unsupported transport protocol \"" + protocol + "\"");
+ BOOST_THROW_EXCEPTION(ConfigFile::Error("Unsupported transport protocol \"" + protocol + "\""));
}
}
@@ -140,7 +140,7 @@
// Use `interestToExpress` to avoid wire format creation for the original Interest
if (interestToExpress->wireEncode().size() > MAX_NDN_PACKET_SIZE)
- throw Error("Interest size exceeds maximum limit");
+ BOOST_THROW_EXCEPTION(Error("Interest size exceeds maximum limit"));
// If the same ioService thread, dispatch directly calls the method
m_ioService.dispatch([=] { m_impl->asyncExpressInterest(interestToExpress, onData, onTimeout); });
@@ -164,7 +164,7 @@
{
// Use original `data`, since wire format should already exist for the original Data
if (data.wireEncode().size() > MAX_NDN_PACKET_SIZE)
- throw Error("Data size exceeds maximum limit");
+ BOOST_THROW_EXCEPTION(Error("Data size exceeds maximum limit"));
shared_ptr<const Data> dataPtr;
try {
diff --git a/src/interest-filter.hpp b/src/interest-filter.hpp
index 6207e18..68cb7d5 100644
--- a/src/interest-filter.hpp
+++ b/src/interest-filter.hpp
@@ -94,8 +94,8 @@
operator const Name&() const
{
if (static_cast<bool>(m_regexFilter)) {
- throw Error("Please update OnInterest callback to accept const InterestFilter& "
- "(non-trivial Interest filter is being used)");
+ BOOST_THROW_EXCEPTION(Error("Please update OnInterest callback to accept const "
+ "InterestFilter& (non-trivial Interest filter is being used)"));
}
return m_prefix;
}
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();
diff --git a/src/key-locator.cpp b/src/key-locator.cpp
index 2f92d5d..151a704 100644
--- a/src/key-locator.cpp
+++ b/src/key-locator.cpp
@@ -65,7 +65,7 @@
totalLength += encoder.prependBlock(m_keyDigest);
break;
default:
- throw Error("Unsupported KeyLocator type");
+ BOOST_THROW_EXCEPTION(Error("Unsupported KeyLocator type"));
}
totalLength += encoder.prependVarNumber(totalLength);
@@ -99,7 +99,7 @@
KeyLocator::wireDecode(const Block& wire)
{
if (wire.type() != tlv::KeyLocator)
- throw Error("Unexpected TLV type during KeyLocator decoding");
+ BOOST_THROW_EXCEPTION(Error("Unexpected TLV type during KeyLocator decoding"));
m_wire = wire;
m_wire.parse();
@@ -138,7 +138,7 @@
KeyLocator::getName() const
{
if (m_type != KeyLocator_Name)
- throw Error("KeyLocator type is not Name");
+ BOOST_THROW_EXCEPTION(Error("KeyLocator type is not Name"));
return m_name;
}
@@ -156,7 +156,7 @@
KeyLocator::getKeyDigest() const
{
if (m_type != KeyLocator_KeyDigest)
- throw Error("KeyLocator type is not KeyDigest");
+ BOOST_THROW_EXCEPTION(Error("KeyLocator type is not KeyDigest"));
return m_keyDigest;
}
@@ -165,7 +165,7 @@
KeyLocator::setKeyDigest(const Block& keyDigest)
{
if (keyDigest.type() != tlv::KeyDigest)
- throw Error("expecting KeyDigest block");
+ BOOST_THROW_EXCEPTION(Error("expecting KeyDigest block"));
this->clear();
m_type = KeyLocator_KeyDigest;
diff --git a/src/link.cpp b/src/link.cpp
index b900450..d4de993 100644
--- a/src/link.cpp
+++ b/src/link.cpp
@@ -144,7 +144,7 @@
if (getContentType() != tlv::ContentType_Link)
{
- throw Error("Expected Content Type Link");
+ BOOST_THROW_EXCEPTION(Error("Expected Content Type Link"));
}
const Block& content = getContent();
@@ -154,18 +154,18 @@
delegation.parse();
Block::element_const_iterator val = delegation.elements_begin();
if (val == delegation.elements_end()) {
- throw Error("Unexpected Link Encoding");
+ BOOST_THROW_EXCEPTION(Error("Unexpected Link Encoding"));
}
uint32_t preference;
try {
preference = static_cast<uint32_t>(readNonNegativeInteger(*val));
}
catch (tlv::Error&) {
- throw Error("Missing preference field in Link Encoding");
+ BOOST_THROW_EXCEPTION(Error("Missing preference field in Link Encoding"));
}
++val;
if (val == delegation.elements_end()) {
- throw Error("Missing name field in Link Encoding");
+ BOOST_THROW_EXCEPTION(Error("Missing name field in Link Encoding"));
}
Name name(*val);
m_delegations.insert({preference, name});
@@ -188,7 +188,7 @@
const Block& delegationBlock = contentBlock.elements().at(index);
delegationBlock.parse();
if (delegationBlock.type() != tlv::LinkDelegation) {
- throw Error("Unexpected TLV-TYPE; expecting LinkDelegation");
+ BOOST_THROW_EXCEPTION(Error("Unexpected TLV-TYPE, expecting LinkDelegation"));
}
return std::make_tuple(
static_cast<uint32_t>(
@@ -206,7 +206,7 @@
for (auto&& delegationBlock : contentBlock.elements()) {
delegationBlock.parse();
if (delegationBlock.type() != tlv::LinkDelegation) {
- throw Error("Unexpected TLV-TYPE; expecting LinkDelegation");
+ BOOST_THROW_EXCEPTION(Error("Unexpected TLV-TYPE, expecting LinkDelegation"));
}
Name name(delegationBlock.get(tlv::Name));
if (name == delegationName) {
diff --git a/src/lp/cache-policy.cpp b/src/lp/cache-policy.cpp
index 6bd1be9..2802b96 100644
--- a/src/lp/cache-policy.cpp
+++ b/src/lp/cache-policy.cpp
@@ -56,7 +56,7 @@
CachePolicy::wireEncode(EncodingImpl<TAG>& encoder) const
{
if (m_policy == CachePolicyType::NONE) {
- throw Error("CachePolicyType must be set");
+ BOOST_THROW_EXCEPTION(Error("CachePolicyType must be set"));
}
size_t length = 0;
length += prependNonNegativeIntegerBlock(encoder, tlv::CachePolicyType,
@@ -76,7 +76,7 @@
CachePolicy::wireEncode() const
{
if (m_policy == CachePolicyType::NONE) {
- throw Error("CachePolicyType must be set");
+ BOOST_THROW_EXCEPTION(Error("CachePolicyType must be set"));
}
if (m_wire.hasWire()) {
@@ -98,7 +98,7 @@
CachePolicy::wireDecode(const Block& wire)
{
if (wire.type() != tlv::CachePolicy) {
- throw Error("expecting CachePolicy block");
+ BOOST_THROW_EXCEPTION(Error("expecting CachePolicy block"));
}
m_wire = wire;
@@ -108,11 +108,11 @@
if (it != m_wire.elements_end() && it->type() == tlv::CachePolicyType) {
m_policy = static_cast<CachePolicyType>(readNonNegativeInteger(*it));
if (this->getPolicy() == CachePolicyType::NONE) {
- throw Error("unknown CachePolicyType");
+ BOOST_THROW_EXCEPTION(Error("unknown CachePolicyType"));
}
}
else {
- throw Error("expecting CachePolicyType block");
+ BOOST_THROW_EXCEPTION(Error("expecting CachePolicyType block"));
}
}
diff --git a/src/lp/detail/field-decl.hpp b/src/lp/detail/field-decl.hpp
index e6fd4aa..0738768 100644
--- a/src/lp/detail/field-decl.hpp
+++ b/src/lp/detail/field-decl.hpp
@@ -44,7 +44,7 @@
decode(const Block& wire)
{
if (wire.type() != TlvType::value) {
- throw ndn::tlv::Error("Unexpected TLV type " + std::to_string(wire.type()));
+ BOOST_THROW_EXCEPTION(ndn::tlv::Error("Unexpected TLV type " + std::to_string(wire.type())));
}
T type;
@@ -60,7 +60,7 @@
decode(const Block& wire)
{
if (wire.type() != TlvType::value) {
- throw ndn::tlv::Error("Unexpected TLV type " + std::to_string(wire.type()));
+ BOOST_THROW_EXCEPTION(ndn::tlv::Error("Unexpected TLV type " + std::to_string(wire.type())));
}
return readNonNegativeInteger(wire);
@@ -74,11 +74,11 @@
decode(const Block& wire)
{
if (wire.type() != TlvType::value) {
- throw ndn::tlv::Error("Unexpected TLV type " + std::to_string(wire.type()));
+ BOOST_THROW_EXCEPTION(ndn::tlv::Error("Unexpected TLV type " + std::to_string(wire.type())));
}
if (wire.value_size() == 0) {
- throw ndn::tlv::Error(std::to_string(wire.type()) + " must not be empty");
+ BOOST_THROW_EXCEPTION(ndn::tlv::Error(std::to_string(wire.type()) + " must not be empty"));
}
return std::make_pair(wire.value_begin(), wire.value_end());
@@ -147,4 +147,4 @@
} // namespace lp
} // namesapce ndn
-#endif // NDN_CXX_LP_DETAIL_FIELD_DECL_HPP
\ No newline at end of file
+#endif // NDN_CXX_LP_DETAIL_FIELD_DECL_HPP
diff --git a/src/lp/nack-header.cpp b/src/lp/nack-header.cpp
index 22fccae..9f3157c 100644
--- a/src/lp/nack-header.cpp
+++ b/src/lp/nack-header.cpp
@@ -96,7 +96,7 @@
NackHeader::wireDecode(const Block& wire)
{
if (wire.type() != tlv::Nack) {
- throw ndn::tlv::Error("expecting Nack block");
+ BOOST_THROW_EXCEPTION(ndn::tlv::Error("expecting Nack block"));
}
m_wire = wire;
@@ -110,7 +110,7 @@
m_reason = static_cast<NackReason>(readNonNegativeInteger(*it));
}
else {
- throw ndn::tlv::Error("expecting NackReason block");
+ BOOST_THROW_EXCEPTION(ndn::tlv::Error("expecting NackReason block"));
}
}
}
diff --git a/src/lp/packet.cpp b/src/lp/packet.cpp
index 20de690..67957af 100644
--- a/src/lp/packet.cpp
+++ b/src/lp/packet.cpp
@@ -97,16 +97,16 @@
detail::FieldInfo info(element.type());
if (!info.isRecognized && !info.canIgnore) {
- throw Error("unknown field cannot be ignored");
+ BOOST_THROW_EXCEPTION(Error("unknown field cannot be ignored"));
}
if (!isFirst) {
if (info.tlvType == prev.tlvType && !info.isRepeatable) {
- throw Error("non-repeatable field cannot be repeated");
+ BOOST_THROW_EXCEPTION(Error("non-repeatable field cannot be repeated"));
}
else if (info.tlvType != prev.tlvType && !detail::compareFieldSortOrder(prev, info)) {
- throw Error("fields are not in correct sort order");
+ BOOST_THROW_EXCEPTION(Error("fields are not in correct sort order"));
}
}
@@ -126,4 +126,4 @@
}
} // namespace lp
-} // namespace ndn
\ No newline at end of file
+} // namespace ndn
diff --git a/src/lp/packet.hpp b/src/lp/packet.hpp
index bf0cb01..0febb75 100644
--- a/src/lp/packet.hpp
+++ b/src/lp/packet.hpp
@@ -110,7 +110,7 @@
}
}
- throw std::out_of_range("Index out of range");
+ BOOST_THROW_EXCEPTION(std::out_of_range("Index out of range"));
}
/**
@@ -155,7 +155,7 @@
add(const typename FIELD::ValueType& value)
{
if (!FIELD::IsRepeatable::value && has<FIELD>()) {
- throw std::length_error("Field cannot be repeated");
+ BOOST_THROW_EXCEPTION(std::length_error("Field cannot be repeated"));
}
EncodingEstimator estimator;
@@ -195,7 +195,7 @@
}
}
- throw std::out_of_range("Index out of range");
+ BOOST_THROW_EXCEPTION(std::out_of_range("Index out of range"));
}
/**
@@ -221,4 +221,4 @@
} // namespace lp
} // namespace ndn
-#endif // NDN_CXX_LP_PACKET_HPP
\ No newline at end of file
+#endif // NDN_CXX_LP_PACKET_HPP
diff --git a/src/management/nfd-channel-status.cpp b/src/management/nfd-channel-status.cpp
index 2c93283..b53d198 100644
--- a/src/management/nfd-channel-status.cpp
+++ b/src/management/nfd-channel-status.cpp
@@ -82,7 +82,7 @@
ChannelStatus::wireDecode(const Block& block)
{
if (block.type() != tlv::nfd::ChannelStatus) {
- throw Error("expecting ChannelStatus block");
+ BOOST_THROW_EXCEPTION(Error("Expecting ChannelStatus block"));
}
m_wire = block;
m_wire.parse();
@@ -93,7 +93,7 @@
++val;
}
else {
- throw Error("missing required LocalUri field");
+ BOOST_THROW_EXCEPTION(Error("Missing required LocalUri field"));
}
}
diff --git a/src/management/nfd-command-options.cpp b/src/management/nfd-command-options.cpp
index 72326c9..8a2b9f7 100644
--- a/src/management/nfd-command-options.cpp
+++ b/src/management/nfd-command-options.cpp
@@ -42,7 +42,7 @@
CommandOptions::setTimeout(const time::milliseconds& timeout)
{
if (timeout <= time::milliseconds::zero()) {
- throw std::out_of_range("timeout must be positive");
+ BOOST_THROW_EXCEPTION(std::out_of_range("Timeout must be positive"));
}
m_timeout = timeout;
@@ -76,7 +76,8 @@
case security::SigningInfo::SIGNER_TYPE_CERT:
return SIGNING_PARAMS_CERTIFICATE;
default:
- throw std::out_of_range("SigningInfo::SignerType is not convertible to CommandOptions::SigningParamsKind");
+ BOOST_THROW_EXCEPTION(std::out_of_range("SigningInfo::SignerType is not convertible to "
+ "CommandOptions::SigningParamsKind"));
}
}
@@ -114,7 +115,7 @@
// A valid IdentityCertificate has at least 4 name components,
// as it follows `<...>/KEY/<...>/<key-id>/ID-CERT/<version>` naming model.
if (certificateName.size() < 4) {
- throw std::invalid_argument("certificate is invalid");
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Certificate is invalid"));
}
return security::signingByCertificate(certificateName);
diff --git a/src/management/nfd-control-command.cpp b/src/management/nfd-control-command.cpp
index 3c87d3f..d8ab2c6 100644
--- a/src/management/nfd-control-command.cpp
+++ b/src/management/nfd-control-command.cpp
@@ -80,11 +80,13 @@
bool isPresent = presentFields[i];
if (m_required[i]) {
if (!isPresent) {
- throw ArgumentError(CONTROL_PARAMETER_FIELD[i] + " is required but missing");
+ BOOST_THROW_EXCEPTION(ArgumentError(CONTROL_PARAMETER_FIELD[i] + " is required but "
+ "missing"));
}
}
else if (isPresent && !m_optional[i]) {
- throw ArgumentError(CONTROL_PARAMETER_FIELD[i] + " is forbidden but present");
+ BOOST_THROW_EXCEPTION(ArgumentError(CONTROL_PARAMETER_FIELD[i] + " is forbidden but "
+ "present"));
}
}
}
@@ -105,7 +107,7 @@
this->ControlCommand::validateResponse(parameters);
if (parameters.getFaceId() == 0) {
- throw ArgumentError("FaceId must not be zero");
+ BOOST_THROW_EXCEPTION(ArgumentError("FaceId must not be zero"));
}
}
@@ -123,7 +125,7 @@
this->ControlCommand::validateRequest(parameters);
if (parameters.getFaceId() == 0) {
- throw ArgumentError("FaceId must not be zero");
+ BOOST_THROW_EXCEPTION(ArgumentError("FaceId must not be zero"));
}
}
@@ -151,7 +153,7 @@
case LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID:
break;
default:
- throw ArgumentError("LocalControlFeature is invalid");
+ BOOST_THROW_EXCEPTION(ArgumentError("LocalControlFeature is invalid"));
}
}
@@ -201,7 +203,7 @@
this->ControlCommand::validateResponse(parameters);
if (parameters.getFaceId() == 0) {
- throw ArgumentError("FaceId must not be zero");
+ BOOST_THROW_EXCEPTION(ArgumentError("FaceId must not be zero"));
}
}
@@ -230,7 +232,7 @@
this->ControlCommand::validateResponse(parameters);
if (parameters.getFaceId() == 0) {
- throw ArgumentError("FaceId must not be zero");
+ BOOST_THROW_EXCEPTION(ArgumentError("FaceId must not be zero"));
}
}
@@ -257,7 +259,7 @@
this->ControlCommand::validateRequest(parameters);
if (parameters.getName().size() == 0) {
- throw ArgumentError("Name must not be ndn:/");
+ BOOST_THROW_EXCEPTION(ArgumentError("Name must not be ndn:/"));
}
}
@@ -309,7 +311,7 @@
this->ControlCommand::validateResponse(parameters);
if (parameters.getFaceId() == 0) {
- throw ArgumentError("FaceId must not be zero");
+ BOOST_THROW_EXCEPTION(ArgumentError("FaceId must not be zero"));
}
}
@@ -343,7 +345,7 @@
this->ControlCommand::validateResponse(parameters);
if (parameters.getFaceId() == 0) {
- throw ArgumentError("FaceId must not be zero");
+ BOOST_THROW_EXCEPTION(ArgumentError("FaceId must not be zero"));
}
}
diff --git a/src/management/nfd-control-parameters.cpp b/src/management/nfd-control-parameters.cpp
index eb9fa0f..f8ce363 100644
--- a/src/management/nfd-control-parameters.cpp
+++ b/src/management/nfd-control-parameters.cpp
@@ -115,7 +115,7 @@
ControlParameters::wireDecode(const Block& block)
{
if (block.type() != tlv::nfd::ControlParameters) {
- throw Error("expecting TLV-TYPE ControlParameters");
+ BOOST_THROW_EXCEPTION(Error("Expecting TLV-TYPE ControlParameters"));
}
m_wire = block;
m_wire.parse();
@@ -168,7 +168,7 @@
if (this->hasStrategy()) {
val->parse();
if (val->elements().empty()) {
- throw Error("expecting Strategy/Name");
+ BOOST_THROW_EXCEPTION(Error("Expecting Strategy/Name"));
}
else {
m_strategy.wireDecode(*val->elements_begin());
diff --git a/src/management/nfd-control-response.cpp b/src/management/nfd-control-response.cpp
index 0c2166c..7056162 100644
--- a/src/management/nfd-control-response.cpp
+++ b/src/management/nfd-control-response.cpp
@@ -74,13 +74,15 @@
m_wire.parse();
if (m_wire.type() != tlv::nfd::ControlResponse)
- throw Error("Requested decoding of ControlResponse, but Block is of different type");
+ BOOST_THROW_EXCEPTION(Error("Requested decoding of ControlResponse, but Block is of different "
+ "type"));
Block::element_const_iterator val = m_wire.elements_begin();
if (val == m_wire.elements_end() ||
val->type() != tlv::nfd::StatusCode)
{
- throw Error("Incorrect ControlResponse format (StatusCode missing or not the first item)");
+ BOOST_THROW_EXCEPTION(Error("Incorrect ControlResponse format (StatusCode missing or not the "
+ "first item)"));
}
m_code = readNonNegativeInteger(*val);
@@ -89,7 +91,8 @@
if (val == m_wire.elements_end() ||
val->type() != tlv::nfd::StatusText)
{
- throw Error("Incorrect ControlResponse format (StatusText missing or not the second item)");
+ BOOST_THROW_EXCEPTION(Error("Incorrect ControlResponse format (StatusText missing or not the "
+ "second item)"));
}
m_text.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
++val;
diff --git a/src/management/nfd-face-event-notification.cpp b/src/management/nfd-face-event-notification.cpp
index 9e757a3..5f80fe8 100644
--- a/src/management/nfd-face-event-notification.cpp
+++ b/src/management/nfd-face-event-notification.cpp
@@ -89,7 +89,7 @@
FaceEventNotification::wireDecode(const Block& block)
{
if (block.type() != tlv::nfd::FaceEventNotification) {
- throw Error("expecting FaceEventNotification block");
+ BOOST_THROW_EXCEPTION(Error("expecting FaceEventNotification block"));
}
m_wire = block;
m_wire.parse();
@@ -100,7 +100,7 @@
++val;
}
else {
- throw Error("missing required FaceEventKind field");
+ BOOST_THROW_EXCEPTION(Error("missing required FaceEventKind field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::FaceId) {
@@ -108,7 +108,7 @@
++val;
}
else {
- throw Error("missing required FaceId field");
+ BOOST_THROW_EXCEPTION(Error("missing required FaceId field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::Uri) {
@@ -116,7 +116,7 @@
++val;
}
else {
- throw Error("missing required Uri field");
+ BOOST_THROW_EXCEPTION(Error("missing required Uri field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::LocalUri) {
@@ -124,7 +124,7 @@
++val;
}
else {
- throw Error("missing required LocalUri field");
+ BOOST_THROW_EXCEPTION(Error("missing required LocalUri field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::FaceScope) {
@@ -132,7 +132,7 @@
++val;
}
else {
- throw Error("missing required FaceScope field");
+ BOOST_THROW_EXCEPTION(Error("missing required FaceScope field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::FacePersistency) {
@@ -140,7 +140,7 @@
++val;
}
else {
- throw Error("missing required FacePersistency field");
+ BOOST_THROW_EXCEPTION(Error("missing required FacePersistency field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::LinkType) {
@@ -148,7 +148,7 @@
++val;
}
else {
- throw Error("missing required LinkType field");
+ BOOST_THROW_EXCEPTION(Error("missing required LinkType field"));
}
}
diff --git a/src/management/nfd-face-query-filter.cpp b/src/management/nfd-face-query-filter.cpp
index 0fa02f2..bd10d2b 100644
--- a/src/management/nfd-face-query-filter.cpp
+++ b/src/management/nfd-face-query-filter.cpp
@@ -122,7 +122,7 @@
{
//all fields are optional
if (block.type() != tlv::nfd::FaceQueryFilter) {
- throw Error("expecting FaceQueryFilter block");
+ BOOST_THROW_EXCEPTION(Error("expecting FaceQueryFilter block"));
}
m_wire = block;
@@ -350,4 +350,3 @@
} // namespace nfd
} // namespace ndn
-
diff --git a/src/management/nfd-face-status.cpp b/src/management/nfd-face-status.cpp
index becaa75..30af9fb 100644
--- a/src/management/nfd-face-status.cpp
+++ b/src/management/nfd-face-status.cpp
@@ -115,7 +115,7 @@
FaceStatus::wireDecode(const Block& block)
{
if (block.type() != tlv::nfd::FaceStatus) {
- throw Error("expecting FaceStatus block");
+ BOOST_THROW_EXCEPTION(Error("expecting FaceStatus block"));
}
m_wire = block;
m_wire.parse();
@@ -126,7 +126,7 @@
++val;
}
else {
- throw Error("missing required FaceId field");
+ BOOST_THROW_EXCEPTION(Error("missing required FaceId field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::Uri) {
@@ -134,7 +134,7 @@
++val;
}
else {
- throw Error("missing required Uri field");
+ BOOST_THROW_EXCEPTION(Error("missing required Uri field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::LocalUri) {
@@ -142,7 +142,7 @@
++val;
}
else {
- throw Error("missing required LocalUri field");
+ BOOST_THROW_EXCEPTION(Error("missing required LocalUri field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::ExpirationPeriod) {
@@ -160,7 +160,7 @@
++val;
}
else {
- throw Error("missing required FaceScope field");
+ BOOST_THROW_EXCEPTION(Error("missing required FaceScope field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::FacePersistency) {
@@ -168,7 +168,7 @@
++val;
}
else {
- throw Error("missing required FacePersistency field");
+ BOOST_THROW_EXCEPTION(Error("missing required FacePersistency field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::LinkType) {
@@ -176,7 +176,7 @@
++val;
}
else {
- throw Error("missing required LinkType field");
+ BOOST_THROW_EXCEPTION(Error("missing required LinkType field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::NInInterests) {
@@ -184,7 +184,7 @@
++val;
}
else {
- throw Error("missing required NInInterests field");
+ BOOST_THROW_EXCEPTION(Error("missing required NInInterests field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::NInDatas) {
@@ -192,7 +192,7 @@
++val;
}
else {
- throw Error("missing required NInDatas field");
+ BOOST_THROW_EXCEPTION(Error("missing required NInDatas field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::NOutInterests) {
@@ -200,7 +200,7 @@
++val;
}
else {
- throw Error("missing required NOutInterests field");
+ BOOST_THROW_EXCEPTION(Error("missing required NOutInterests field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::NOutDatas) {
@@ -208,7 +208,7 @@
++val;
}
else {
- throw Error("missing required NOutDatas field");
+ BOOST_THROW_EXCEPTION(Error("missing required NOutDatas field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::NInBytes) {
@@ -216,7 +216,7 @@
++val;
}
else {
- throw Error("missing required NInBytes field");
+ BOOST_THROW_EXCEPTION(Error("missing required NInBytes field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::NOutBytes) {
@@ -224,7 +224,7 @@
++val;
}
else {
- throw Error("missing required NOutBytes field");
+ BOOST_THROW_EXCEPTION(Error("missing required NOutBytes field"));
}
}
diff --git a/src/management/nfd-fib-entry.cpp b/src/management/nfd-fib-entry.cpp
index b8c5274..fb07329 100644
--- a/src/management/nfd-fib-entry.cpp
+++ b/src/management/nfd-fib-entry.cpp
@@ -124,31 +124,31 @@
std::stringstream error;
error << "Requested decoding of NextHopRecord, but Block is of a different type: #"
<< m_wire.type();
- throw Error(error.str());
+ BOOST_THROW_EXCEPTION(Error(error.str()));
}
m_wire.parse();
Block::element_const_iterator val = m_wire.elements_begin();
if (val == m_wire.elements_end()) {
- throw Error("Unexpected end of NextHopRecord");
+ BOOST_THROW_EXCEPTION(Error("Unexpected end of NextHopRecord"));
}
else if (val->type() != tlv::nfd::FaceId) {
std::stringstream error;
error << "Expected FaceId, but Block is of a different type: #"
<< val->type();
- throw Error(error.str());
+ BOOST_THROW_EXCEPTION(Error(error.str()));
}
m_faceId = readNonNegativeInteger(*val);
++val;
if (val == m_wire.elements_end()) {
- throw Error("Unexpected end of NextHopRecord");
+ BOOST_THROW_EXCEPTION(Error("Unexpected end of NextHopRecord"));
}
else if (val->type() != tlv::nfd::Cost) {
std::stringstream error;
error << "Expected Cost, but Block is of a different type: #"
<< m_wire.type();
- throw Error(error.str());
+ BOOST_THROW_EXCEPTION(Error(error.str()));
}
m_cost = readNonNegativeInteger(*val);
}
@@ -235,20 +235,20 @@
std::stringstream error;
error << "Requested decoding of FibEntry, but Block is of a different type: #"
<< m_wire.type();
- throw Error(error.str());
+ BOOST_THROW_EXCEPTION(Error(error.str()));
}
m_wire.parse();
Block::element_const_iterator val = m_wire.elements_begin();
if (val == m_wire.elements_end()) {
- throw Error("Unexpected end of FibEntry");
+ BOOST_THROW_EXCEPTION(Error("Unexpected end of FibEntry"));
}
else if (val->type() != tlv::Name) {
std::stringstream error;
error << "Expected Name, but Block is of a different type: #"
<< val->type();
- throw Error(error.str());
+ BOOST_THROW_EXCEPTION(Error(error.str()));
}
m_prefix.wireDecode(*val);
++val;
@@ -258,7 +258,7 @@
std::stringstream error;
error << "Expected NextHopRecords, but Block is of a different type: #"
<< val->type();
- throw Error(error.str());
+ BOOST_THROW_EXCEPTION(Error(error.str()));
}
m_nextHopRecords.push_back(NextHopRecord(*val));
}
diff --git a/src/management/nfd-forwarder-status.cpp b/src/management/nfd-forwarder-status.cpp
index 4e989ee..81b3bb9 100644
--- a/src/management/nfd-forwarder-status.cpp
+++ b/src/management/nfd-forwarder-status.cpp
@@ -116,7 +116,7 @@
ForwarderStatus::wireDecode(const Block& block)
{
if (block.type() != tlv::Content) {
- throw Error("expecting Content block for Status payload");
+ BOOST_THROW_EXCEPTION(Error("expecting Content block for Status payload"));
}
m_wire = block;
m_wire.parse();
@@ -127,7 +127,7 @@
++val;
}
else {
- throw Error("missing required NfdVersion field");
+ BOOST_THROW_EXCEPTION(Error("missing required NfdVersion field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::StartTimestamp) {
@@ -135,7 +135,7 @@
++val;
}
else {
- throw Error("missing required StartTimestamp field");
+ BOOST_THROW_EXCEPTION(Error("missing required StartTimestamp field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::CurrentTimestamp) {
@@ -143,7 +143,7 @@
++val;
}
else {
- throw Error("missing required CurrentTimestamp field");
+ BOOST_THROW_EXCEPTION(Error("missing required CurrentTimestamp field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::NNameTreeEntries) {
@@ -151,7 +151,7 @@
++val;
}
else {
- throw Error("missing required NNameTreeEntries field");
+ BOOST_THROW_EXCEPTION(Error("missing required NNameTreeEntries field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::NFibEntries) {
@@ -159,7 +159,7 @@
++val;
}
else {
- throw Error("missing required NFibEntries field");
+ BOOST_THROW_EXCEPTION(Error("missing required NFibEntries field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::NPitEntries) {
@@ -167,7 +167,7 @@
++val;
}
else {
- throw Error("missing required NPitEntries field");
+ BOOST_THROW_EXCEPTION(Error("missing required NPitEntries field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::NMeasurementsEntries) {
@@ -175,7 +175,7 @@
++val;
}
else {
- throw Error("missing required NMeasurementsEntries field");
+ BOOST_THROW_EXCEPTION(Error("missing required NMeasurementsEntries field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::NCsEntries) {
@@ -183,7 +183,7 @@
++val;
}
else {
- throw Error("missing required NCsEntries field");
+ BOOST_THROW_EXCEPTION(Error("missing required NCsEntries field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::NInInterests) {
@@ -191,7 +191,7 @@
++val;
}
else {
- throw Error("missing required NInInterests field");
+ BOOST_THROW_EXCEPTION(Error("missing required NInInterests field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::NInDatas) {
@@ -199,7 +199,7 @@
++val;
}
else {
- throw Error("missing required NInDatas field");
+ BOOST_THROW_EXCEPTION(Error("missing required NInDatas field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::NOutInterests) {
@@ -207,7 +207,7 @@
++val;
}
else {
- throw Error("missing required NOutInterests field");
+ BOOST_THROW_EXCEPTION(Error("missing required NOutInterests field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::NOutDatas) {
@@ -215,7 +215,7 @@
++val;
}
else {
- throw Error("missing required NOutDatas field");
+ BOOST_THROW_EXCEPTION(Error("missing required NOutDatas field"));
}
}
diff --git a/src/management/nfd-local-control-header.hpp b/src/management/nfd-local-control-header.hpp
index 8108230..327035d 100644
--- a/src/management/nfd-local-control-header.hpp
+++ b/src/management/nfd-local-control-header.hpp
@@ -250,7 +250,8 @@
{
/// @todo should this be BOOST_ASSERT instead? This is kind of unnecessary overhead
if (empty(encodeMask))
- throw Error("Requested wire for LocalControlHeader, but none of the fields are set or enabled");
+ BOOST_THROW_EXCEPTION(Error("Requested wire for LocalControlHeader, but none of the fields are "
+ "set or enabled"));
EncodingEstimator estimator;
size_t length = wireEncode(estimator, payload.wireEncode().size(), encodeMask);
@@ -297,7 +298,7 @@
m_cachingPolicy = CachingPolicy::NO_CACHE;
}
else {
- throw Error("CachingPolicy: Missing required NoCache field");
+ BOOST_THROW_EXCEPTION(Error("CachingPolicy: Missing required NoCache field"));
}
}
break;
diff --git a/src/management/nfd-rib-entry.cpp b/src/management/nfd-rib-entry.cpp
index ab78d5c..7c056cd 100644
--- a/src/management/nfd-rib-entry.cpp
+++ b/src/management/nfd-rib-entry.cpp
@@ -130,7 +130,7 @@
std::stringstream error;
error << "Expected Route Block, but Block is of a different type: #"
<< m_wire.type();
- throw Error(error.str());
+ BOOST_THROW_EXCEPTION(Error(error.str()));
}
m_wire.parse();
@@ -142,7 +142,7 @@
++val;
}
else {
- throw Error("Missing required FaceId field");
+ BOOST_THROW_EXCEPTION(Error("Missing required FaceId field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::Origin) {
@@ -150,7 +150,7 @@
++val;
}
else {
- throw Error("Missing required Origin field");
+ BOOST_THROW_EXCEPTION(Error("Missing required Origin field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::Cost) {
@@ -158,7 +158,7 @@
++val;
}
else {
- throw Error("Missing required Cost field");
+ BOOST_THROW_EXCEPTION(Error("Missing required Cost field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::Flags) {
@@ -166,7 +166,7 @@
++val;
}
else {
- throw Error("Missing required Flags field");
+ BOOST_THROW_EXCEPTION(Error("Missing required Flags field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::ExpirationPeriod) {
@@ -272,7 +272,7 @@
std::stringstream error;
error << "Expected RibEntry Block, but Block is of a different type: #"
<< m_wire.type();
- throw Error(error.str());
+ BOOST_THROW_EXCEPTION(Error(error.str()));
}
m_wire.parse();
@@ -284,7 +284,7 @@
++val;
}
else {
- throw Error("Missing required Name field");
+ BOOST_THROW_EXCEPTION(Error("Missing required Name field"));
}
for (; val != m_wire.elements_end(); ++val) {
@@ -296,7 +296,7 @@
std::stringstream error;
error << "Expected Route Block, but Block is of a different type: #"
<< m_wire.type();
- throw Error(error.str());
+ BOOST_THROW_EXCEPTION(Error(error.str()));
}
}
}
diff --git a/src/management/nfd-strategy-choice.cpp b/src/management/nfd-strategy-choice.cpp
index 6283acd..659293c 100644
--- a/src/management/nfd-strategy-choice.cpp
+++ b/src/management/nfd-strategy-choice.cpp
@@ -82,7 +82,7 @@
StrategyChoice::wireDecode(const Block& block)
{
if (block.type() != tlv::nfd::StrategyChoice) {
- throw Error("expecting StrategyChoice block");
+ BOOST_THROW_EXCEPTION(Error("expecting StrategyChoice block"));
}
m_wire = block;
m_wire.parse();
@@ -93,13 +93,13 @@
++val;
}
else {
- throw Error("missing required Name field");
+ BOOST_THROW_EXCEPTION(Error("missing required Name field"));
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::Strategy) {
val->parse();
if (val->elements().empty()) {
- throw Error("expecting Strategy/Name");
+ BOOST_THROW_EXCEPTION(Error("expecting Strategy/Name"));
}
else {
m_strategy.wireDecode(*val->elements_begin());
@@ -107,7 +107,7 @@
++val;
}
else {
- throw Error("missing required Strategy field");
+ BOOST_THROW_EXCEPTION(Error("missing required Strategy field"));
}
}
diff --git a/src/meta-info.cpp b/src/meta-info.cpp
index a1bfa18..1fb2d9f 100644
--- a/src/meta-info.cpp
+++ b/src/meta-info.cpp
@@ -78,7 +78,8 @@
{
for (std::list<Block>::const_iterator i = info.begin(); i != info.end(); ++i) {
if (!(128 <= i->type() && i->type() <= 252))
- throw Error("AppMetaInfo block has type outside the application range [128, 252]");
+ BOOST_THROW_EXCEPTION(Error("AppMetaInfo block has type outside the application range "
+ "[128, 252]"));
}
m_wire.reset();
@@ -90,7 +91,8 @@
MetaInfo::addAppMetaInfo(const Block& block)
{
if (!(128 <= block.type() && block.type() <= 252))
- throw Error("AppMetaInfo block has type outside the application range [128, 252]");
+ BOOST_THROW_EXCEPTION(Error("AppMetaInfo block has type outside the application range "
+ "[128, 252]"));
m_wire.reset();
m_appMetaInfo.push_back(block);
diff --git a/src/name-component.cpp b/src/name-component.cpp
index dbe9998..9226eb4 100644
--- a/src/name-component.cpp
+++ b/src/name-component.cpp
@@ -59,8 +59,8 @@
: Block(wire)
{
if (!isGeneric() && !isImplicitSha256Digest())
- throw Error("Cannot construct name::Component from not a NameComponent "
- "or ImplicitSha256DigestComponent TLV wire block");
+ BOOST_THROW_EXCEPTION(Error("Cannot construct name::Component from not a NameComponent "
+ "or ImplicitSha256DigestComponent TLV wire block"));
}
Component::Component(const ConstBufferPtr& buffer)
@@ -98,15 +98,16 @@
if (trimmedString.compare(0, getSha256DigestUriPrefix().size(),
getSha256DigestUriPrefix()) == 0) {
if (trimmedString.size() != getSha256DigestUriPrefix().size() + crypto::SHA256_DIGEST_SIZE * 2)
- throw Error("Cannot convert to ImplicitSha256DigestComponent"
- "(expected sha256 in hex encoding)");
+ BOOST_THROW_EXCEPTION(Error("Cannot convert to ImplicitSha256DigestComponent"
+ "(expected sha256 in hex encoding)"));
try {
trimmedString.erase(0, getSha256DigestUriPrefix().size());
return fromImplicitSha256Digest(fromHex(trimmedString));
}
catch (StringHelperError& e) {
- throw Error("Cannot convert to a ImplicitSha256DigestComponent (invalid hex encoding)");
+ BOOST_THROW_EXCEPTION(Error("Cannot convert to a ImplicitSha256DigestComponent (invalid hex "
+ "encoding)"));
}
}
else {
@@ -116,7 +117,7 @@
// Special case for component of only periods.
if (value.size() <= 2)
// Zero, one or two periods is illegal. Ignore this component.
- throw Error("Illegal URI (name component cannot be . or ..)");
+ BOOST_THROW_EXCEPTION(Error("Illegal URI (name component cannot be . or ..)"));
else
// Remove 3 periods.
return Component(reinterpret_cast<const uint8_t*>(&value[3]), value.size() - 3);
@@ -238,7 +239,7 @@
Component::toNumber() const
{
if (!isNumber())
- throw Error("Name component does not have nonNegativeInteger value");
+ BOOST_THROW_EXCEPTION(Error("Name component does not have nonNegativeInteger value"));
return readNonNegativeInteger(*this);
}
@@ -247,8 +248,8 @@
Component::toNumberWithMarker(uint8_t marker) const
{
if (!isNumberWithMarker(marker))
- throw Error("Name component does not have the requested marker "
- "or the value is not a nonNegativeInteger");
+ BOOST_THROW_EXCEPTION(Error("Name component does not have the requested marker "
+ "or the value is not a nonNegativeInteger"));
Buffer::const_iterator valueBegin = value_begin() + 1;
return tlv::readNonNegativeInteger(value_size() - 1, valueBegin, value_end());
@@ -364,8 +365,8 @@
Component::fromImplicitSha256Digest(const ConstBufferPtr& digest)
{
if (digest->size() != crypto::SHA256_DIGEST_SIZE)
- throw Error("Cannot create ImplicitSha256DigestComponent (input digest must be " +
- boost::lexical_cast<std::string>(crypto::SHA256_DIGEST_SIZE) + " octets)");
+ BOOST_THROW_EXCEPTION(Error("Cannot create ImplicitSha256DigestComponent (input digest must be " +
+ std::to_string(crypto::SHA256_DIGEST_SIZE) + " octets)"));
return Block(tlv::ImplicitSha256DigestComponent, digest);
}
@@ -374,8 +375,8 @@
Component::fromImplicitSha256Digest(const uint8_t* digest, size_t digestSize)
{
if (digestSize != crypto::SHA256_DIGEST_SIZE)
- throw Error("Cannot create ImplicitSha256DigestComponent (input digest must be " +
- boost::lexical_cast<std::string>(crypto::SHA256_DIGEST_SIZE) + " octets)");
+ BOOST_THROW_EXCEPTION(Error("Cannot create ImplicitSha256DigestComponent (input digest must be "
+ + std::to_string(crypto::SHA256_DIGEST_SIZE) + " octets)"));
return makeBinaryBlock(tlv::ImplicitSha256DigestComponent, digest, digestSize);
}
diff --git a/src/name.cpp b/src/name.cpp
index 1ba3bfd..2e2dd6c 100644
--- a/src/name.cpp
+++ b/src/name.cpp
@@ -108,7 +108,7 @@
Name::wireDecode(const Block& wire)
{
if (wire.type() != tlv::Name)
- throw tlv::Error("Unexpected TLV type when decoding Name");
+ BOOST_THROW_EXCEPTION(tlv::Error("Unexpected TLV type when decoding Name"));
m_nameBlock = wire;
m_nameBlock.parse();
diff --git a/src/name.hpp b/src/name.hpp
index d6040e6..7e228b7 100644
--- a/src/name.hpp
+++ b/src/name.hpp
@@ -443,7 +443,7 @@
{
if ((i >= 0 && static_cast<size_t>(i) >= size()) ||
(i < 0 && static_cast<size_t>(-i) > size()))
- throw Error("Requested component does not exist (out of bounds)");
+ BOOST_THROW_EXCEPTION(Error("Requested component does not exist (out of bounds)"));
return get(i);
}
diff --git a/src/security/additional-description.cpp b/src/security/additional-description.cpp
index 6aed34a..c912638 100644
--- a/src/security/additional-description.cpp
+++ b/src/security/additional-description.cpp
@@ -46,7 +46,7 @@
{
auto it = m_info.find(key);
if (it == m_info.end())
- throw Error("Entry does not exist for key (" + key + ")");
+ BOOST_THROW_EXCEPTION(Error("Entry does not exist for key (" + key + ")"));
return it->second;
}
@@ -136,14 +136,14 @@
AdditionalDescription::wireDecode(const Block& wire)
{
if (!wire.hasWire()) {
- throw Error("The supplied block does not contain wire format");
+ BOOST_THROW_EXCEPTION(Error("The supplied block does not contain wire format"));
}
m_wire = wire;
m_wire.parse();
if (m_wire.type() != tlv::AdditionalDescription)
- throw Error("Unexpected TLV type when decoding AdditionalDescription");
+ BOOST_THROW_EXCEPTION(Error("Unexpected TLV type when decoding AdditionalDescription"));
Block::element_const_iterator it = m_wire.elements_begin();
while (it != m_wire.elements_end()) {
@@ -151,14 +151,14 @@
entry.parse();
if (entry.type() != tlv::DescriptionEntry)
- throw Error("Unexpected TLV type when decoding DescriptionEntry");
+ BOOST_THROW_EXCEPTION(Error("Unexpected TLV type when decoding DescriptionEntry"));
if (entry.elements_size() != 2)
- throw Error("DescriptionEntry does not have two sub-TLVs");
+ BOOST_THROW_EXCEPTION(Error("DescriptionEntry does not have two sub-TLVs"));
if (entry.elements()[KEY_OFFSET].type() != tlv::DescriptionKey ||
entry.elements()[VALUE_OFFSET].type() != tlv::DescriptionValue)
- throw Error("Invalid DescriptionKey or DescriptionValue field");
+ BOOST_THROW_EXCEPTION(Error("Invalid DescriptionKey or DescriptionValue field"));
m_info[readString(entry.elements()[KEY_OFFSET])] = readString(entry.elements()[VALUE_OFFSET]);
it++;
diff --git a/src/security/certificate.cpp b/src/security/certificate.cpp
index e25a92e..837872a 100644
--- a/src/security/certificate.cpp
+++ b/src/security/certificate.cpp
@@ -261,7 +261,7 @@
idCert.MessageEnd();
}
catch (CryptoPP::BERDecodeErr&) {
- throw Error("Certificate Decoding Error");
+ BOOST_THROW_EXCEPTION(Error("Certificate Decoding Error"));
}
}
diff --git a/src/security/conf/checker.hpp b/src/security/conf/checker.hpp
index 1364229..bb651bc 100644
--- a/src/security/conf/checker.hpp
+++ b/src/security/conf/checker.hpp
@@ -104,14 +104,14 @@
case tlv::SignatureSha256WithEcdsa:
{
if (!static_cast<bool>(m_keyLocatorChecker))
- throw Error("Strong signature requires KeyLocatorChecker");
+ BOOST_THROW_EXCEPTION(Error("Strong signature requires KeyLocatorChecker"));
return;
}
case tlv::DigestSha256:
return;
default:
- throw Error("Unsupported signature type");
+ BOOST_THROW_EXCEPTION(Error("Unsupported signature type"));
}
}
@@ -245,7 +245,7 @@
if (sigType != tlv::SignatureSha256WithRsa &&
sigType != tlv::SignatureSha256WithEcdsa)
{
- throw Error("FixedSigner is only meaningful for strong signature type");
+ BOOST_THROW_EXCEPTION(Error("FixedSigner is only meaningful for strong signature type"));
}
}
@@ -389,7 +389,7 @@
// Get checker.type
if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "type"))
- throw Error("Expect <checker.type>");
+ BOOST_THROW_EXCEPTION(Error("Expect <checker.type>"));
std::string type = propertyIt->second.data();
@@ -400,7 +400,7 @@
else if (boost::iequals(type, "fixed-signer"))
return createFixedSignerChecker(configSection, configFilename);
else
- throw Error("Unsupported checker type: " + type);
+ BOOST_THROW_EXCEPTION(Error("Unsupported checker type: " + type));
}
private:
@@ -413,21 +413,21 @@
// Get checker.sig-type
if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "sig-type"))
- throw Error("Expect <checker.sig-type>");
+ BOOST_THROW_EXCEPTION(Error("Expect <checker.sig-type>"));
std::string sigType = propertyIt->second.data();
propertyIt++;
// Get checker.key-locator
if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "key-locator"))
- throw Error("Expect <checker.key-locator>");
+ BOOST_THROW_EXCEPTION(Error("Expect <checker.key-locator>"));
shared_ptr<KeyLocatorChecker> keyLocatorChecker =
KeyLocatorCheckerFactory::create(propertyIt->second, configFilename);
propertyIt++;
if (propertyIt != configSection.end())
- throw Error("Expect the end of checker");
+ BOOST_THROW_EXCEPTION(Error("Expect the end of checker"));
return make_shared<CustomizedChecker>(getSigType(sigType), keyLocatorChecker);
}
@@ -441,13 +441,13 @@
// Get checker.sig-type
if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "sig-type"))
- throw Error("Expect <checker.sig-type>");
+ BOOST_THROW_EXCEPTION(Error("Expect <checker.sig-type>"));
std::string sigType = propertyIt->second.data();
propertyIt++;
if (propertyIt != configSection.end())
- throw Error("Expect the end of checker");
+ BOOST_THROW_EXCEPTION(Error("Expect the end of checker"));
return make_shared<HierarchicalChecker>(getSigType(sigType));
}
@@ -461,7 +461,7 @@
// Get checker.sig-type
if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "sig-type"))
- throw Error("Expect <checker.sig-type>");
+ BOOST_THROW_EXCEPTION(Error("Expect <checker.sig-type>"));
std::string sigType = propertyIt->second.data();
propertyIt++;
@@ -470,14 +470,14 @@
for (; propertyIt != configSection.end(); propertyIt++)
{
if (!boost::iequals(propertyIt->first, "signer"))
- throw Error("Expect <checker.signer> but get <checker." +
- propertyIt->first + ">");
+ BOOST_THROW_EXCEPTION(Error("Expect <checker.signer> but get <checker." +
+ propertyIt->first + ">"));
signers.push_back(getSigner(propertyIt->second, configFilename));
}
if (propertyIt != configSection.end())
- throw Error("Expect the end of checker");
+ BOOST_THROW_EXCEPTION(Error("Expect the end of checker"));
return shared_ptr<FixedSignerChecker>(new FixedSignerChecker(getSigType(sigType),
signers));
@@ -492,7 +492,7 @@
// Get checker.signer.type
if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "type"))
- throw Error("Expect <checker.signer.type>");
+ BOOST_THROW_EXCEPTION(Error("Expect <checker.signer.type>"));
std::string type = propertyIt->second.data();
propertyIt++;
@@ -501,14 +501,14 @@
{
// Get checker.signer.file-name
if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "file-name"))
- throw Error("Expect <checker.signer.file-name>");
+ BOOST_THROW_EXCEPTION(Error("Expect <checker.signer.file-name>"));
path certfilePath = absolute(propertyIt->second.data(),
path(configFilename).parent_path());
propertyIt++;
if (propertyIt != configSection.end())
- throw Error("Expect the end of checker.signer");
+ BOOST_THROW_EXCEPTION(Error("Expect the end of checker.signer"));
shared_ptr<IdentityCertificate> idCert
= io::load<IdentityCertificate>(certfilePath.c_str());
@@ -516,31 +516,31 @@
if (static_cast<bool>(idCert))
return idCert;
else
- throw Error("Cannot read certificate from file: " +
- certfilePath.native());
+ BOOST_THROW_EXCEPTION(Error("Cannot read certificate from file: " +
+ certfilePath.native()));
}
else if (boost::iequals(type, "base64"))
{
// Get checker.signer.base64-string
if (propertyIt == configSection.end() ||
!boost::iequals(propertyIt->first, "base64-string"))
- throw Error("Expect <checker.signer.base64-string>");
+ BOOST_THROW_EXCEPTION(Error("Expect <checker.signer.base64-string>"));
std::stringstream ss(propertyIt->second.data());
propertyIt++;
if (propertyIt != configSection.end())
- throw Error("Expect the end of checker.signer");
+ BOOST_THROW_EXCEPTION(Error("Expect the end of checker.signer"));
shared_ptr<IdentityCertificate> idCert = io::load<IdentityCertificate>(ss);
if (static_cast<bool>(idCert))
return idCert;
else
- throw Error("Cannot decode certificate from string");
+ BOOST_THROW_EXCEPTION(Error("Cannot decode certificate from string"));
}
else
- throw Error("Unsupported checker.signer type: " + type);
+ BOOST_THROW_EXCEPTION(Error("Unsupported checker.signer type: " + type));
}
static uint32_t
@@ -553,7 +553,7 @@
else if (boost::iequals(sigType, "sha256"))
return tlv::DigestSha256;
else
- throw Error("Unsupported signature type");
+ BOOST_THROW_EXCEPTION(Error("Unsupported signature type"));
}
};
diff --git a/src/security/conf/filter.hpp b/src/security/conf/filter.hpp
index 8d0601c..3dfddde 100644
--- a/src/security/conf/filter.hpp
+++ b/src/security/conf/filter.hpp
@@ -152,14 +152,14 @@
ConfigSection::const_iterator propertyIt = configSection.begin();
if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "type"))
- throw Error("Expect <filter.type>!");
+ BOOST_THROW_EXCEPTION(Error("Expect <filter.type>!"));
std::string type = propertyIt->second.data();
if (boost::iequals(type, "name"))
return createNameFilter(configSection);
else
- throw Error("Unsupported filter.type: " + type);
+ BOOST_THROW_EXCEPTION(Error("Unsupported filter.type: " + type));
}
private:
static shared_ptr<Filter>
@@ -169,7 +169,7 @@
propertyIt++;
if (propertyIt == configSection.end())
- throw Error("Expect more properties for filter(name)");
+ BOOST_THROW_EXCEPTION(Error("Expect more properties for filter(name)"));
if (boost::iequals(propertyIt->first, "name"))
{
@@ -181,14 +181,14 @@
}
catch (Name::Error& e)
{
- throw Error("Wrong filter.name: " + propertyIt->second.data());
+ BOOST_THROW_EXCEPTION(Error("Wrong filter.name: " + propertyIt->second.data()));
}
propertyIt++;
// Get filter.relation
if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "relation"))
- throw Error("Expect <filter.relation>!");
+ BOOST_THROW_EXCEPTION(Error("Expect <filter.relation>!"));
std::string relationString = propertyIt->second.data();
propertyIt++;
@@ -201,11 +201,11 @@
else if (boost::iequals(relationString, "is-strict-prefix-of"))
relation = RelationNameFilter::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 filter!");
+ BOOST_THROW_EXCEPTION(Error("Expect the end of filter!"));
return make_shared<RelationNameFilter>(name, relation);
}
@@ -215,7 +215,7 @@
propertyIt++;
if (propertyIt != configSection.end())
- throw Error("Expect the end of filter!");
+ BOOST_THROW_EXCEPTION(Error("Expect the end of filter!"));
try
{
@@ -223,11 +223,11 @@
}
catch (Regex::Error& e)
{
- throw Error("Wrong filter.regex: " + regexString);
+ BOOST_THROW_EXCEPTION(Error("Wrong filter.regex: " + regexString));
}
}
else
- throw Error("Wrong filter(name) properties");
+ BOOST_THROW_EXCEPTION(Error("Wrong filter(name) properties"));
}
};
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"));
}
};
diff --git a/src/security/digest-sha256.cpp b/src/security/digest-sha256.cpp
index 3af551a..6e37eb5 100644
--- a/src/security/digest-sha256.cpp
+++ b/src/security/digest-sha256.cpp
@@ -32,7 +32,7 @@
: Signature(signature)
{
if (getType() != tlv::DigestSha256)
- throw Error("Incorrect signature type");
+ BOOST_THROW_EXCEPTION(Error("Incorrect signature type"));
}
} // namespace ndn
diff --git a/src/security/identity-certificate.cpp b/src/security/identity-certificate.cpp
index a80684e..1eaceac 100644
--- a/src/security/identity-certificate.cpp
+++ b/src/security/identity-certificate.cpp
@@ -94,7 +94,7 @@
IdentityCertificate::setPublicKeyName()
{
if (!isCorrectName(getName()))
- throw Error("Wrong Identity Certificate Name!");
+ BOOST_THROW_EXCEPTION(Error("Wrong Identity Certificate Name"));
m_publicKeyName = certificateNameToPublicKeyName(getName());
}
@@ -120,7 +120,7 @@
}
if (!foundIdString)
- throw Error("Incorrect identity certificate name " + certificateName.toUri());
+ BOOST_THROW_EXCEPTION(Error("Incorrect identity certificate name " + certificateName.toUri()));
Name tmpName = certificateName.getSubName(0, idCertComponentIndex);
string keyString("KEY");
@@ -135,7 +135,7 @@
}
if (!foundKeyString)
- throw Error("Incorrect identity certificate name " + certificateName.toUri());
+ BOOST_THROW_EXCEPTION(Error("Incorrect identity certificate name " + certificateName.toUri()));
return tmpName
.getSubName(0, keyComponentIndex)
diff --git a/src/security/identity.cpp b/src/security/identity.cpp
index 128b7bc..1093b9f 100644
--- a/src/security/identity.cpp
+++ b/src/security/identity.cpp
@@ -46,7 +46,7 @@
if (needInit)
m_impl->addIdentity(m_name);
else if (!m_impl->hasIdentity(m_name))
- throw Pib::Error("Identity: " + m_name.toUri() + " does not exist");
+ BOOST_THROW_EXCEPTION(Pib::Error("Identity: " + m_name.toUri() + " does not exist"));
}
const Name&
@@ -157,7 +157,7 @@
Identity::validityCheck() const
{
if (m_impl == nullptr)
- throw std::domain_error("Invalid Identity instance");
+ BOOST_THROW_EXCEPTION(std::domain_error("Invalid Identity instance"));
}
} // namespace security
diff --git a/src/security/key-chain.cpp b/src/security/key-chain.cpp
index 2950a50..16bc879 100644
--- a/src/security/key-chain.cpp
+++ b/src/security/key-chain.cpp
@@ -177,7 +177,7 @@
auto pibFactory = getPibFactories().find(pibScheme);
if (pibFactory == getPibFactories().end()) {
- throw KeyChain::Error("PIB scheme '" + pibScheme + "' is not supported");
+ BOOST_THROW_EXCEPTION(KeyChain::Error("PIB scheme '" + pibScheme + "' is not supported"));
}
pibScheme = pibFactory->second.canonicalName;
@@ -214,7 +214,7 @@
}
auto tpmFactory = getTpmFactories().find(tpmScheme);
if (tpmFactory == getTpmFactories().end()) {
- throw KeyChain::Error("TPM scheme '" + tpmScheme + "' is not supported");
+ BOOST_THROW_EXCEPTION(KeyChain::Error("TPM scheme '" + tpmScheme + "' is not supported"));
}
tpmScheme = tpmFactory->second.canonicalName;
@@ -256,8 +256,8 @@
if (!allowReset &&
!m_pib->getTpmLocator().empty() && m_pib->getTpmLocator() != canonicalTpmLocator)
// Tpm mismatch, but we do not want to reset PIB
- throw MismatchError("TPM locator supplied does not match TPM locator in PIB: " +
- m_pib->getTpmLocator() + " != " + canonicalTpmLocator);
+ BOOST_THROW_EXCEPTION(MismatchError("TPM locator supplied does not match TPM locator in PIB: "
+ + m_pib->getTpmLocator() + " != " + canonicalTpmLocator));
}
catch (SecPublicInfo::Error&) {
// TPM locator is not set in PIB yet.
@@ -482,7 +482,7 @@
signingCertName = m_pib->getDefaultCertificateNameForKey(params.getSignerName());
}
catch (SecPublicInfo::Error&) {
- throw Error("signing certificate does not exist");
+ BOOST_THROW_EXCEPTION(Error("signing certificate does not exist"));
}
signingCert = m_pib->getCertificate(signingCertName);
@@ -493,7 +493,7 @@
{
signingCert = m_pib->getCertificate(params.getSignerName());
if (signingCert == nullptr)
- throw Error("signing certificate does not exist");
+ BOOST_THROW_EXCEPTION(Error("signing certificate does not exist"));
break;
}
@@ -503,7 +503,7 @@
return std::make_tuple(DIGEST_SHA256_IDENTITY, sigInfo);
}
default:
- throw Error("Unrecognized signer type");
+ BOOST_THROW_EXCEPTION(Error("Unrecognized signer type"));
}
sigInfo.setSignatureType(getSignatureType(signingCert->getPublicKeyInfo().getKeyType(),
@@ -540,7 +540,7 @@
shared_ptr<IdentityCertificate> certificate = m_pib->getCertificate(certificateName);
if (certificate == nullptr)
- throw SecPublicInfo::Error("certificate does not exist");
+ BOOST_THROW_EXCEPTION(SecPublicInfo::Error("certificate does not exist"));
Signature sig;
@@ -587,7 +587,7 @@
{
Name keyName = cert.getPublicKeyName();
if (!m_tpm->doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE))
- throw SecTpm::Error("Private key does not exist");
+ BOOST_THROW_EXCEPTION(SecTpm::Error("Private key does not exist"));
SignatureInfo sigInfo(cert.getSignature().getInfo());
sigInfo.setKeyLocator(KeyLocator(cert.getName().getPrefix(-1)));
@@ -601,7 +601,7 @@
KeyChain::exportIdentity(const Name& identity, const std::string& passwordStr)
{
if (!m_pib->doesIdentityExist(identity))
- throw SecPublicInfo::Error("Identity does not exist");
+ BOOST_THROW_EXCEPTION(SecPublicInfo::Error("Identity does not exist"));
Name keyName = m_pib->getDefaultKeyNameForIdentity(identity);
@@ -612,7 +612,7 @@
}
catch (SecTpm::Error& e)
{
- throw SecPublicInfo::Error("Fail to export PKCS5 of private key");
+ BOOST_THROW_EXCEPTION(SecPublicInfo::Error("Fail to export PKCS5 of private key"));
}
shared_ptr<IdentityCertificate> cert;
@@ -842,7 +842,7 @@
case KEY_TYPE_ECDSA:
return tlv::SignatureSha256WithEcdsa;
default:
- throw Error("Unsupported key types");
+ BOOST_THROW_EXCEPTION(Error("Unsupported key types"));
}
}
diff --git a/src/security/key-params.hpp b/src/security/key-params.hpp
index d4840a2..1c911f4 100644
--- a/src/security/key-params.hpp
+++ b/src/security/key-params.hpp
@@ -128,7 +128,7 @@
SimplePublicKeyParams(const KeyParams& params)
: KeyParams(params.getKeyType())
{
- throw KeyParams::Error("Incorrect key parameters (incompatible key type)");
+ BOOST_THROW_EXCEPTION(KeyParams::Error("Incorrect key parameters (incompatible key type)"));
}
uint32_t
@@ -202,7 +202,7 @@
explicit
SimpleSymmetricKeyParams(const KeyParams& params)
{
- throw KeyParams::Error("Incorrect key parameters (incompatible key type)");
+ BOOST_THROW_EXCEPTION(KeyParams::Error("Incorrect key parameters (incompatible key type)"));
}
uint32_t
diff --git a/src/security/key.cpp b/src/security/key.cpp
index dc430c7..48c8aa3 100644
--- a/src/security/key.cpp
+++ b/src/security/key.cpp
@@ -194,7 +194,7 @@
Key::validityCheck() const
{
if (m_impl == nullptr)
- throw std::domain_error("Invalid Key instance");
+ BOOST_THROW_EXCEPTION(std::domain_error("Invalid Key instance"));
}
} // namespace security
diff --git a/src/security/pib-memory.cpp b/src/security/pib-memory.cpp
index 397b0db..09300f1 100644
--- a/src/security/pib-memory.cpp
+++ b/src/security/pib-memory.cpp
@@ -33,7 +33,7 @@
void
PibMemory::setTpmLocator(const std::string& tpmLocator)
{
- throw Error("PibMemory does not need a locator");
+ BOOST_THROW_EXCEPTION(Error("PibMemory does not need a locator"));
}
std::string
@@ -92,7 +92,7 @@
if (m_hasDefaultIdentity)
return m_defaultIdentity;
- throw Pib::Error("No default identity");
+ BOOST_THROW_EXCEPTION(Pib::Error("No default identity"));
}
bool
@@ -131,7 +131,7 @@
PibMemory::getKeyBits(const Name& identity, const name::Component& keyId) const
{
if (!hasKey(identity, keyId))
- throw Pib::Error("No key");
+ BOOST_THROW_EXCEPTION(Pib::Error("No key"));
auto it = m_keys.find(getKeyName(identity, keyId));
return it->second;
@@ -154,7 +154,7 @@
Name keyName = getKeyName(identity, keyId);
if (!hasKey(identity, keyId))
- throw Pib::Error("No key");
+ BOOST_THROW_EXCEPTION(Pib::Error("No key"));
m_defaultKey[identity] = keyName;
}
@@ -164,7 +164,7 @@
{
auto it = m_defaultKey.find(identity);
if (it == m_defaultKey.end())
- throw Pib::Error("No default key");
+ BOOST_THROW_EXCEPTION(Pib::Error("No default key"));
return it->second.get(-1);
}
@@ -208,7 +208,7 @@
PibMemory::getCertificate(const Name& certName) const
{
if (!hasCertificate(certName))
- throw Pib::Error("No cert");
+ BOOST_THROW_EXCEPTION(Pib::Error("No cert"));
auto it = m_certs.find(certName);
return it->second;
@@ -231,7 +231,7 @@
PibMemory::setDefaultCertificateOfKey(const Name& identity, const name::Component& keyId, const Name& certName)
{
if (!hasCertificate(certName))
- throw Pib::Error("No cert");
+ BOOST_THROW_EXCEPTION(Pib::Error("No cert"));
Name keyName = getKeyName(identity, keyId);
m_defaultCert[keyName] = certName;
@@ -244,11 +244,11 @@
auto it = m_defaultCert.find(keyName);
if (it == m_defaultCert.end())
- throw Pib::Error("No default certificate");
+ BOOST_THROW_EXCEPTION(Pib::Error("No default certificate"));
auto certIt = m_certs.find(it->second);
if (certIt == m_certs.end())
- throw Pib::Error("No default certificate");
+ BOOST_THROW_EXCEPTION(Pib::Error("No default certificate"));
else
return certIt->second;
}
diff --git a/src/security/pib-sqlite3.cpp b/src/security/pib-sqlite3.cpp
index 3a95b5d..b20ee7c 100644
--- a/src/security/pib-sqlite3.cpp
+++ b/src/security/pib-sqlite3.cpp
@@ -217,7 +217,7 @@
boost::filesystem::path actualDir;
if (dir == "") {
if (getenv("HOME") == nullptr)
- throw PibImpl::Error("Environment variable HOME is not set");
+ BOOST_THROW_EXCEPTION(PibImpl::Error("Environment variable HOME is not set"));
actualDir = boost::filesystem::path(getenv("HOME")) / ".ndn";
boost::filesystem::create_directories(actualDir);
@@ -237,7 +237,7 @@
);
if (result != SQLITE_OK)
- throw PibImpl::Error("PIB DB cannot be opened/created: " + dir);
+ BOOST_THROW_EXCEPTION(PibImpl::Error("PIB DB cannot be opened/created: " + dir));
// enable foreign key
@@ -248,7 +248,7 @@
result = sqlite3_exec(m_database, INITIALIZATION.c_str(), nullptr, nullptr, &errorMessage);
if (result != SQLITE_OK && errorMessage != nullptr) {
sqlite3_free(errorMessage);
- throw PibImpl::Error("PIB DB cannot be initialized");
+ BOOST_THROW_EXCEPTION(PibImpl::Error("PIB DB cannot be initialized"));
}
}
@@ -282,7 +282,7 @@
if (res == SQLITE_ROW)
return statement.getString(0);
else
- throw Pib::Error("TPM info does not exist");
+ BOOST_THROW_EXCEPTION(Pib::Error("TPM info does not exist"));
}
bool
@@ -337,7 +337,7 @@
if (statement.step() == SQLITE_ROW)
return Name(statement.getBlock(0));
else
- throw Pib::Error("No default identity");
+ BOOST_THROW_EXCEPTION(Pib::Error("No default identity"));
}
bool
@@ -395,7 +395,7 @@
if (statement.step() == SQLITE_ROW)
return PublicKey(statement.getBlob(0), statement.getSize(0));
else
- throw Pib::Error("Key does not exist");
+ BOOST_THROW_EXCEPTION(Pib::Error("Key does not exist"));
}
std::set<name::Component>
@@ -423,7 +423,7 @@
Name keyName = getKeyName(identity, keyId);
if (!hasKey(identity, keyId)) {
- throw Pib::Error("No such key");
+ BOOST_THROW_EXCEPTION(Pib::Error("No such key"));
}
Sqlite3Statement statement(m_database, "UPDATE keys SET is_default=1 WHERE key_name=?");
@@ -435,7 +435,7 @@
PibSqlite3::getDefaultKeyOfIdentity(const Name& identity) const
{
if (!hasIdentity(identity)) {
- throw Pib::Error("Identity does not exist");
+ BOOST_THROW_EXCEPTION(Pib::Error("Identity does not exist"));
}
Sqlite3Statement statement(m_database,
@@ -449,7 +449,7 @@
return keyName.get(-1);
}
else
- throw Pib::Error("No default key");
+ BOOST_THROW_EXCEPTION(Pib::Error("No default key"));
}
bool
@@ -500,7 +500,7 @@
if (statement.step() == SQLITE_ROW)
return IdentityCertificate(statement.getBlock(0));
else
- throw Pib::Error("Certificate does not exit");
+ BOOST_THROW_EXCEPTION(Pib::Error("Certificate does not exit"));
}
std::set<Name>
@@ -527,7 +527,7 @@
const Name& certName)
{
if (!hasCertificate(certName)) {
- throw Pib::Error("Certificate does not exist");
+ BOOST_THROW_EXCEPTION(Pib::Error("Certificate does not exist"));
}
Sqlite3Statement statement(m_database,
@@ -550,7 +550,7 @@
if (statement.step() == SQLITE_ROW)
return IdentityCertificate(statement.getBlock(0));
else
- throw Pib::Error("Certificate does not exit");
+ BOOST_THROW_EXCEPTION(Pib::Error("Certificate does not exit"));
}
} // namespace security
diff --git a/src/security/public-key.cpp b/src/security/public-key.cpp
index 07b8137..5e0a607 100644
--- a/src/security/public-key.cpp
+++ b/src/security/public-key.cpp
@@ -46,7 +46,7 @@
PublicKey::computeDigest() const
{
if (m_key.empty())
- throw Error("Public key is empty");
+ BOOST_THROW_EXCEPTION(Error("Public key is empty"));
if (m_digest.hasWire())
return m_digest;
@@ -110,8 +110,8 @@
else if (algorithm == oid::ECDSA)
m_type = KEY_TYPE_ECDSA;
else
- throw Error("Only RSA/ECDSA public keys are supported for now (" +
- algorithm.toString() + " requested)");
+ BOOST_THROW_EXCEPTION(Error("Only RSA/ECDSA public keys are supported for now (" +
+ algorithm.toString() + " requested)"));
}
}
@@ -120,7 +120,7 @@
catch (CryptoPP::BERDecodeErr& err)
{
m_type = KEY_TYPE_NULL;
- throw Error("PublicKey decoding error");
+ BOOST_THROW_EXCEPTION(Error("PublicKey decoding error"));
}
m_digest.reset();
diff --git a/src/security/sec-public-info-sqlite3.cpp b/src/security/sec-public-info-sqlite3.cpp
index 65e394c..462f215 100644
--- a/src/security/sec-public-info-sqlite3.cpp
+++ b/src/security/sec-public-info-sqlite3.cpp
@@ -130,7 +130,7 @@
#endif
);
if (res != SQLITE_OK)
- throw Error("identity DB cannot be opened/created");
+ BOOST_THROW_EXCEPTION(Error("identity DB cannot be opened/created"));
BOOST_ASSERT(m_database != nullptr);
@@ -228,7 +228,7 @@
}
else {
sqlite3_finalize(statement);
- throw SecPublicInfo::Error("TPM info does not exist");
+ BOOST_THROW_EXCEPTION(SecPublicInfo::Error("TPM info does not exist"));
}
}
@@ -321,7 +321,7 @@
SecPublicInfoSqlite3::doesPublicKeyExist(const Name& keyName)
{
if (keyName.empty())
- throw Error("Incorrect key name " + keyName.toUri());
+ BOOST_THROW_EXCEPTION(Error("Incorrect key name " + keyName.toUri()));
string keyId = keyName.get(-1).toUri();
Name identityName = keyName.getPrefix(-1);
@@ -387,7 +387,7 @@
SecPublicInfoSqlite3::getPublicKey(const Name& keyName)
{
if (keyName.empty())
- throw Error("SecPublicInfoSqlite3::getPublicKey Empty keyName");
+ BOOST_THROW_EXCEPTION(Error("SecPublicInfoSqlite3::getPublicKey Empty keyName"));
string keyId = keyName.get(-1).toUri();
Name identityName = keyName.getPrefix(-1);
@@ -411,7 +411,7 @@
}
else {
sqlite3_finalize(statement);
- throw Error("SecPublicInfoSqlite3::getPublicKey public key does not exist");
+ BOOST_THROW_EXCEPTION(Error("SecPublicInfoSqlite3::getPublicKey public key does not exist"));
}
}
@@ -545,7 +545,8 @@
}
catch (tlv::Error&) {
sqlite3_finalize(statement);
- throw Error("SecPublicInfoSqlite3::getCertificate certificate cannot be decoded");
+ BOOST_THROW_EXCEPTION(Error("SecPublicInfoSqlite3::getCertificate certificate cannot be "
+ "decoded"));
}
sqlite3_finalize(statement);
@@ -553,7 +554,8 @@
}
else {
sqlite3_finalize(statement);
- throw Error("SecPublicInfoSqlite3::getCertificate certificate does not exist");
+ BOOST_THROW_EXCEPTION(Error("SecPublicInfoSqlite3::getCertificate certificate does not "
+ "exist"));
}
}
@@ -575,7 +577,7 @@
}
else {
sqlite3_finalize(statement);
- throw Error("SecPublicInfoSqlite3::getDefaultIdentity no default identity");
+ BOOST_THROW_EXCEPTION(Error("SecPublicInfoSqlite3::getDefaultIdentity no default identity"));
}
}
@@ -629,7 +631,8 @@
}
else {
sqlite3_finalize(statement);
- throw Error("SecPublicInfoSqlite3::getDefaultKeyNameForIdentity key not found");
+ BOOST_THROW_EXCEPTION(Error("SecPublicInfoSqlite3::getDefaultKeyNameForIdentity key not "
+ "found"));
}
}
@@ -637,7 +640,7 @@
SecPublicInfoSqlite3::setDefaultKeyNameForIdentityInternal(const Name& keyName)
{
if (!doesPublicKeyExist(keyName))
- throw Error("Key does not exist:" + keyName.toUri());
+ BOOST_THROW_EXCEPTION(Error("Key does not exist:" + keyName.toUri()));
string keyId = keyName.get(-1).toUri();
Name identityName = keyName.getPrefix(-1);
@@ -673,7 +676,7 @@
SecPublicInfoSqlite3::getDefaultCertificateNameForKey(const Name& keyName)
{
if (keyName.empty())
- throw Error("SecPublicInfoSqlite3::getDefaultCertificateNameForKey wrong key");
+ BOOST_THROW_EXCEPTION(Error("SecPublicInfoSqlite3::getDefaultCertificateNameForKey wrong key"));
string keyId = keyName.get(-1).toUri();
Name identityName = keyName.getPrefix(-1);
@@ -697,7 +700,7 @@
}
else {
sqlite3_finalize(statement);
- throw Error("certificate not found");
+ BOOST_THROW_EXCEPTION(Error("certificate not found"));
}
}
@@ -705,7 +708,7 @@
SecPublicInfoSqlite3::setDefaultCertificateNameForKeyInternal(const Name& certificateName)
{
if (!doesCertificateExist(certificateName))
- throw Error("certificate does not exist:" + certificateName.toUri());
+ BOOST_THROW_EXCEPTION(Error("certificate does not exist:" + certificateName.toUri()));
Name keyName = IdentityCertificate::certificateNameToPublicKeyName(certificateName);
string keyId = keyName.get(-1).toUri();
diff --git a/src/security/sec-public-info.cpp b/src/security/sec-public-info.cpp
index 6d9cc4c..2226f51 100644
--- a/src/security/sec-public-info.cpp
+++ b/src/security/sec-public-info.cpp
@@ -78,7 +78,7 @@
refreshDefaultCertificate();
if (m_defaultCertificate == nullptr)
- throw Error("No default certificate is set");
+ BOOST_THROW_EXCEPTION(Error("No default certificate is set"));
return m_defaultCertificate->getName();
}
@@ -98,7 +98,7 @@
Name keyName = Name(identityName).append(oss.str());
if (doesPublicKeyExist(keyName))
- throw Error("Key name already exists: " + keyName.toUri());
+ BOOST_THROW_EXCEPTION(Error("Key name already exists: " + keyName.toUri()));
return keyName;
}
diff --git a/src/security/sec-rule-relative.cpp b/src/security/sec-rule-relative.cpp
index 042d04f..4bf5eb9 100644
--- a/src/security/sec-rule-relative.cpp
+++ b/src/security/sec-rule-relative.cpp
@@ -46,7 +46,7 @@
m_signerNameRegex(signerRegex, signerExpand)
{
if (op != ">" && op != ">=" && op != "==")
- throw Error("op is wrong!");
+ BOOST_THROW_EXCEPTION(Error("op is wrong"));
}
SecRuleRelative::~SecRuleRelative()
diff --git a/src/security/sec-tpm-file.cpp b/src/security/sec-tpm-file.cpp
index 4551ce5..e20fa94 100644
--- a/src/security/sec-tpm-file.cpp
+++ b/src/security/sec-tpm-file.cpp
@@ -113,9 +113,9 @@
string keyURI = keyName.toUri();
if (doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC))
- throw Error("public key exists");
+ BOOST_THROW_EXCEPTION(Error("public key exists"));
if (doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE))
- throw Error("private key exists");
+ BOOST_THROW_EXCEPTION(Error("private key exists"));
string keyFileName = m_impl->maintainMapping(keyURI);
@@ -194,16 +194,16 @@
return;
}
default:
- throw Error("Unsupported key type!");
+ BOOST_THROW_EXCEPTION(Error("Unsupported key type"));
}
}
catch (KeyParams::Error& e)
{
- throw Error(e.what());
+ BOOST_THROW_EXCEPTION(Error(e.what()));
}
catch (CryptoPP::Exception& e)
{
- throw Error(e.what());
+ BOOST_THROW_EXCEPTION(Error(e.what()));
}
}
@@ -226,7 +226,7 @@
string keyURI = keyName.toUri();
if (!doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC))
- throw Error("Public Key does not exist");
+ BOOST_THROW_EXCEPTION(Error("Public Key does not exist"));
ostringstream os;
try
@@ -238,7 +238,7 @@
}
catch (CryptoPP::Exception& e)
{
- throw Error(e.what());
+ BOOST_THROW_EXCEPTION(Error(e.what()));
}
return make_shared<PublicKey>(reinterpret_cast<const uint8_t*>(os.str().c_str()),
@@ -308,7 +308,7 @@
string keyURI = keyName.toUri();
if (!doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE))
- throw Error("private key doesn't exists");
+ BOOST_THROW_EXCEPTION(Error("private key doesn't exist"));
try
{
@@ -347,7 +347,7 @@
return Block(tlv::SignatureValue, os.buf());
}
default:
- throw Error("Unsupported digest algorithm!");
+ BOOST_THROW_EXCEPTION(Error("Unsupported digest algorithm"));
}
}
case KEY_TYPE_ECDSA:
@@ -383,16 +383,16 @@
return Block(tlv::SignatureValue, sigBuffer);
}
default:
- throw Error("Unsupported digest algorithm!");
+ BOOST_THROW_EXCEPTION(Error("Unsupported digest algorithm"));
}
}
default:
- throw Error("Unsupported key type!");
+ BOOST_THROW_EXCEPTION(Error("Unsupported key type"));
}
}
catch (CryptoPP::Exception& e)
{
- throw Error(e.what());
+ BOOST_THROW_EXCEPTION(Error(e.what()));
}
}
@@ -401,7 +401,7 @@
SecTpmFile::decryptInTpm(const uint8_t* data, size_t dataLength,
const Name& keyName, bool isSymmetric)
{
- throw Error("SecTpmFile::decryptInTpm is not supported!");
+ BOOST_THROW_EXCEPTION(Error("SecTpmFile::decryptInTpm is not supported"));
// string keyURI = keyName.toUri();
// if (!isSymmetric)
// {
@@ -463,7 +463,7 @@
SecTpmFile::encryptInTpm(const uint8_t* data, size_t dataLength,
const Name& keyName, bool isSymmetric)
{
- throw Error("SecTpmFile::encryptInTpm is not supported!");
+ BOOST_THROW_EXCEPTION(Error("SecTpmFile::encryptInTpm is not supported"));
// string keyURI = keyName.toUri();
// if (!isSymmetric)
@@ -521,11 +521,10 @@
// }
}
-
void
SecTpmFile::generateSymmetricKeyInTpm(const Name& keyName, const KeyParams& params)
{
- throw Error("SecTpmFile::generateSymmetricKeyInTpm is not supported!");
+ BOOST_THROW_EXCEPTION(Error("SecTpmFile::generateSymmetricKeyInTpm is not supported"));
// string keyURI = keyName.toUri();
// if (doesKeyExistInTpm(keyName, KEY_CLASS_SYMMETRIC))
diff --git a/src/security/sec-tpm-osx.cpp b/src/security/sec-tpm-osx.cpp
index 4400343..33a2c7f 100644
--- a/src/security/sec-tpm-osx.cpp
+++ b/src/security/sec-tpm-osx.cpp
@@ -250,7 +250,7 @@
OSStatus res = SecKeychainCopyDefault(&m_impl->m_keyChainRef);
if (res == errSecNoDefaultKeychain) //If no default key chain, create one.
- throw Error("No default keychain, create one first!");
+ BOOST_THROW_EXCEPTION(Error("No default keychain, please create one first"));
}
SecTpmOsx::~SecTpmOsx()
@@ -377,7 +377,7 @@
if (doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC))
{
- throw Error("keyName has existed");
+ BOOST_THROW_EXCEPTION(Error("keyName already exists"));
}
string keyNameUri = m_impl->toInternalKeyName(keyName, KEY_CLASS_PUBLIC);
@@ -410,7 +410,7 @@
break;
}
default:
- throw Error("Fail to create a key pair: Unsupported key type");
+ BOOST_THROW_EXCEPTION(Error("Fail to create a key pair: Unsupported key type"));
}
CFReleaser<CFNumberRef> cfKeySize = CFNumberCreate(0, kCFNumberIntType, &keySize);
@@ -434,11 +434,11 @@
if (unlockTpm(0, 0, false))
generateKeyPairInTpmInternal(keyName, params, true);
else
- throw Error("Fail to unlock the keychain");
+ BOOST_THROW_EXCEPTION(Error("Fail to unlock the keychain"));
}
else
{
- throw Error("Fail to create a key pair");
+ BOOST_THROW_EXCEPTION(Error("Fail to create a key pair"));
}
}
@@ -473,7 +473,7 @@
void
SecTpmOsx::generateSymmetricKeyInTpm(const Name& keyName, const KeyParams& params)
{
- throw Error("SecTpmOsx::generateSymmetricKeyInTpm is not supported");
+ BOOST_THROW_EXCEPTION(Error("SecTpmOsx::generateSymmetricKeyInTpm is not supported"));
// if (doesKeyExistInTpm(keyName, KEY_CLASS_SYMMETRIC))
// throw Error("keyName has existed!");
@@ -511,7 +511,8 @@
CFReleaser<SecKeychainItemRef> publicKey = m_impl->getKey(keyName, KEY_CLASS_PUBLIC);
if (publicKey.get() == 0)
{
- throw Error("Requested public key [" + keyName.toUri() + "] does not exist in OSX Keychain");
+ BOOST_THROW_EXCEPTION(Error("Requested public key [" + keyName.toUri() + "] does not exist "
+ "in OSX Keychain"));
}
CFReleaser<CFDataRef> exportedKey;
@@ -522,7 +523,7 @@
&exportedKey.get());
if (res != errSecSuccess)
{
- throw Error("Cannot export requested public key from OSX Keychain");
+ BOOST_THROW_EXCEPTION(Error("Cannot export requested public key from OSX Keychain"));
}
shared_ptr<PublicKey> key = make_shared<PublicKey>(CFDataGetBytePtr(exportedKey.get()),
@@ -545,7 +546,8 @@
if (privateKey.get() == 0)
{
/// @todo Can this happen because of keychain is locked?
- throw Error("Private key [" + keyName.toUri() + "] does not exist in OSX Keychain");
+ BOOST_THROW_EXCEPTION(Error("Private key [" + keyName.toUri() + "] does not exist "
+ "in OSX Keychain"));
}
shared_ptr<PublicKey> publicKey = getPublicKeyFromTpm(keyName);
@@ -597,8 +599,8 @@
break;
}
default:
- throw Error("Unsupported key type" +
- boost::lexical_cast<std::string>(publicKey->getKeyType()));
+ BOOST_THROW_EXCEPTION(Error("Unsupported key type" +
+ boost::lexical_cast<std::string>(publicKey->getKeyType())));
}
OBufferStream pkcs8Os;
@@ -813,7 +815,8 @@
CFReleaser<SecKeychainItemRef> privateKey = m_impl->getKey(keyName, KEY_CLASS_PRIVATE);
if (privateKey.get() == 0)
{
- throw Error("Private key [" + keyName.toUri() + "] does not exist in OSX Keychain");
+ BOOST_THROW_EXCEPTION(Error("Private key [" + keyName.toUri() + "] does not exist "
+ "in OSX Keychain"));
}
CFReleaser<CFErrorRef> error;
@@ -821,7 +824,7 @@
CFReleaser<SecTransformRef> signer = SecSignTransformCreate((SecKeyRef)privateKey.get(),
&error.get());
if (error.get() != 0)
- throw Error("Fail to create signer");
+ BOOST_THROW_EXCEPTION(Error("Fail to create signer"));
// Set input
SecTransformSetAttribute(signer.get(),
@@ -829,7 +832,7 @@
dataRef.get(),
&error.get());
if (error.get() != 0)
- throw Error("Fail to configure input of signer");
+ BOOST_THROW_EXCEPTION(Error("Fail to configure input of signer"));
// Enable use of padding
SecTransformSetAttribute(signer.get(),
@@ -837,7 +840,7 @@
kSecPaddingPKCS1Key,
&error.get());
if (error.get() != 0)
- throw Error("Fail to configure digest algorithm of signer");
+ BOOST_THROW_EXCEPTION(Error("Fail to configure digest algorithm of signer"));
// Set padding type
SecTransformSetAttribute(signer.get(),
@@ -845,7 +848,7 @@
m_impl->getDigestAlgorithm(digestAlgorithm),
&error.get());
if (error.get() != 0)
- throw Error("Fail to configure digest algorithm of signer");
+ BOOST_THROW_EXCEPTION(Error("Fail to configure digest algorithm of signer"));
// Set padding attribute
long digestSize = m_impl->getDigestSize(digestAlgorithm);
@@ -855,7 +858,7 @@
cfDigestSize.get(),
&error.get());
if (error.get() != 0)
- throw Error("Fail to configure digest size of signer");
+ BOOST_THROW_EXCEPTION(Error("Fail to configure digest size of signer"));
// Actually sign
// C-style cast is used as per Apple convention
@@ -867,17 +870,17 @@
if (unlockTpm(0, 0, false))
return signInTpmInternal(data, dataLength, keyName, digestAlgorithm, true);
else
- throw Error("Fail to unlock the keychain");
+ BOOST_THROW_EXCEPTION(Error("Fail to unlock the keychain"));
}
else
{
CFShow(error.get());
- throw Error("Fail to sign data");
+ BOOST_THROW_EXCEPTION(Error("Fail to sign data"));
}
}
if (signature.get() == 0)
- throw Error("Signature is NULL!\n");
+ BOOST_THROW_EXCEPTION(Error("Signature is NULL!\n"));
return Block(tlv::SignatureValue,
make_shared<Buffer>(CFDataGetBytePtr(signature.get()),
@@ -887,7 +890,7 @@
ConstBufferPtr
SecTpmOsx::decryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool sym)
{
- throw Error("SecTpmOsx::decryptInTpm is not supported");
+ BOOST_THROW_EXCEPTION(Error("SecTpmOsx::decryptInTpm is not supported"));
// KeyClass keyClass;
// if (sym)
@@ -936,7 +939,8 @@
CFReleaser<SecKeychainItemRef> privateKey = m_impl->getKey(keyName, keyClass);
if (privateKey.get() == 0)
{
- throw Error("Private key [" + keyName.toUri() + "] does not exist in OSX Keychain");
+ BOOST_THROW_EXCEPTION(Error("Private key [" + keyName.toUri() + "] does not exist "
+ "in OSX Keychain"));
}
CFReleaser<SecAccessRef> accRef;
@@ -978,7 +982,7 @@
ConstBufferPtr
SecTpmOsx::encryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool sym)
{
- throw Error("SecTpmOsx::encryptInTpm is not supported");
+ BOOST_THROW_EXCEPTION(Error("SecTpmOsx::encryptInTpm is not supported"));
// KeyClass keyClass;
// if (sym)
diff --git a/src/security/sec-tpm.cpp b/src/security/sec-tpm.cpp
index 5c12049..c84b2de 100644
--- a/src/security/sec-tpm.cpp
+++ b/src/security/sec-tpm.cpp
@@ -57,7 +57,7 @@
// derive key
if (!generateRandomBlock(salt, 8) || !generateRandomBlock(iv, 8))
- throw Error("Cannot generate salt or iv");
+ BOOST_THROW_EXCEPTION(Error("Cannot generate salt or iv"));
uint32_t iterationCount = 2048;
@@ -74,7 +74,7 @@
}
catch (CryptoPP::Exception& e)
{
- throw Error("Cannot derived the encryption key");
+ BOOST_THROW_EXCEPTION(Error("Cannot derived the encryption key"));
}
//encrypt
@@ -84,7 +84,7 @@
ConstBufferPtr pkcs8PrivateKey = exportPrivateKeyPkcs8FromTpm(keyName);
if (!static_cast<bool>(pkcs8PrivateKey))
- throw Error("Cannot export the private key, #1");
+ BOOST_THROW_EXCEPTION(Error("Cannot export the private key, #1"));
OBufferStream encryptedOs;
try
@@ -94,7 +94,7 @@
}
catch (CryptoPP::Exception& e)
{
- throw Error("Cannot export the private key, #2");
+ BOOST_THROW_EXCEPTION(Error("Cannot export the private key, #2"));
}
//encode
@@ -166,7 +166,7 @@
}
catch (CryptoPP::Exception& e)
{
- throw Error("Cannot export the private key, #3");
+ BOOST_THROW_EXCEPTION(Error("Cannot export the private key, #3"));
}
}
diff --git a/src/security/signature-sha256-with-ecdsa.cpp b/src/security/signature-sha256-with-ecdsa.cpp
index 642912b..7de71a2 100644
--- a/src/security/signature-sha256-with-ecdsa.cpp
+++ b/src/security/signature-sha256-with-ecdsa.cpp
@@ -32,17 +32,17 @@
: Signature(signature)
{
if (getType() != tlv::SignatureSha256WithEcdsa)
- throw Error("Incorrect signature type");
+ BOOST_THROW_EXCEPTION(Error("Incorrect signature type"));
if (!hasKeyLocator()) {
- throw Error("KeyLocator is missing");
+ BOOST_THROW_EXCEPTION(Error("KeyLocator is missing"));
}
}
void
SignatureSha256WithEcdsa::unsetKeyLocator()
{
- throw Error("KeyLocator cannot be reset for SignatureSha256WithEcdsa");
+ BOOST_THROW_EXCEPTION(Error("KeyLocator cannot be reset for SignatureSha256WithEcdsa"));
}
} // namespace ndn
diff --git a/src/security/signature-sha256-with-rsa.cpp b/src/security/signature-sha256-with-rsa.cpp
index cda06e6..572257d 100644
--- a/src/security/signature-sha256-with-rsa.cpp
+++ b/src/security/signature-sha256-with-rsa.cpp
@@ -32,17 +32,17 @@
: Signature(signature)
{
if (getType() != tlv::SignatureSha256WithRsa)
- throw Error("Incorrect signature type");
+ BOOST_THROW_EXCEPTION(Error("Incorrect signature type"));
if (!hasKeyLocator()) {
- throw Error("KeyLocator is missing");
+ BOOST_THROW_EXCEPTION(Error("KeyLocator is missing"));
}
}
void
SignatureSha256WithRsa::unsetKeyLocator()
{
- throw Error("KeyLocator cannot be reset for SignatureSha256WithRsa");
+ BOOST_THROW_EXCEPTION(Error("KeyLocator cannot be reset for SignatureSha256WithRsa"));
}
} // namespace ndn
diff --git a/src/security/validator-config.cpp b/src/security/validator-config.cpp
index 149c5dc..c9dbf4d 100644
--- a/src/security/validator-config.cpp
+++ b/src/security/validator-config.cpp
@@ -82,7 +82,7 @@
{
std::string msg = "Failed to read configuration file: ";
msg += filename;
- throw security::conf::Error(msg);
+ BOOST_THROW_EXCEPTION(security::conf::Error(msg));
}
load(inputFile, filename);
inputFile.close();
@@ -110,7 +110,7 @@
msg << "Failed to parse configuration file";
msg << " " << filename;
msg << " " << error.message() << " line " << error.line();
- throw security::conf::Error(msg.str());
+ BOOST_THROW_EXCEPTION(security::conf::Error(msg.str()));
}
load(tree, filename);
@@ -130,7 +130,7 @@
msg += ": ";
msg += filename;
msg += " no data";
- throw security::conf::Error(msg);
+ BOOST_THROW_EXCEPTION(security::conf::Error(msg));
}
for (security::conf::ConfigSection::const_iterator i = configSection.begin();
@@ -153,7 +153,7 @@
msg += " ";
msg += filename;
msg += " unrecognized section: " + sectionName;
- throw security::conf::Error(msg);
+ BOOST_THROW_EXCEPTION(security::conf::Error(msg));
}
}
}
@@ -168,14 +168,14 @@
// Get rule.id
if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "id"))
- throw Error("Expect <rule.id>!");
+ BOOST_THROW_EXCEPTION(Error("Expect <rule.id>!"));
std::string ruleId = propertyIt->second.data();
propertyIt++;
// Get rule.for
if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first,"for"))
- throw Error("Expect <rule.for> in rule: " + ruleId + "!");
+ BOOST_THROW_EXCEPTION(Error("Expect <rule.for> in rule: " + ruleId + "!"));
std::string usage = propertyIt->second.data();
propertyIt++;
@@ -186,8 +186,8 @@
else if (boost::iequals(usage, "interest"))
isForData = false;
else
- throw Error("Unrecognized <rule.for>: " + usage
- + " in rule: " + ruleId);
+ BOOST_THROW_EXCEPTION(Error("Unrecognized <rule.for>: " + usage
+ + " in rule: " + ruleId));
// Get rule.filter(s)
std::vector<shared_ptr<Filter> > filters;
@@ -197,7 +197,7 @@
{
if (boost::iequals(propertyIt->first, "checker"))
break;
- throw Error("Expect <rule.filter> in rule: " + ruleId);
+ BOOST_THROW_EXCEPTION(Error("Expect <rule.filter> in rule: " + ruleId));
}
filters.push_back(FilterFactory::create(propertyIt->second));
@@ -209,7 +209,7 @@
for (; propertyIt != configSection.end(); propertyIt++)
{
if (!boost::iequals(propertyIt->first, "checker"))
- throw Error("Expect <rule.checker> in rule: " + ruleId);
+ BOOST_THROW_EXCEPTION(Error("Expect <rule.checker> in rule: " + ruleId));
checkers.push_back(CheckerFactory::create(propertyIt->second, filename));
continue;
@@ -217,10 +217,10 @@
// Check other stuff
if (propertyIt != configSection.end())
- throw Error("Expect the end of rule: " + ruleId);
+ BOOST_THROW_EXCEPTION(Error("Expect the end of rule: " + ruleId));
if (checkers.size() == 0)
- throw Error("No <rule.checker> is specified in rule: " + ruleId);
+ BOOST_THROW_EXCEPTION(Error("No <rule.checker> is specified in rule: " + ruleId));
if (isForData)
{
@@ -255,7 +255,7 @@
// Get trust-anchor.type
if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "type"))
- throw Error("Expect <trust-anchor.type>!");
+ BOOST_THROW_EXCEPTION(Error("Expect <trust-anchor.type>!"));
std::string type = propertyIt->second.data();
propertyIt++;
@@ -264,14 +264,14 @@
{
// Get trust-anchor.file
if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first,"file-name"))
- throw Error("Expect <trust-anchor.file-name>!");
+ BOOST_THROW_EXCEPTION(Error("Expect <trust-anchor.file-name>!"));
std::string file = propertyIt->second.data();
propertyIt++;
// Check other stuff
if (propertyIt != configSection.end())
- throw Error("Expect the end of trust-anchor!");
+ BOOST_THROW_EXCEPTION(Error("Expect the end of trust-anchor!"));
path certfilePath = absolute(file, path(filename).parent_path());
shared_ptr<IdentityCertificate> idCert =
@@ -284,8 +284,8 @@
m_anchors[idCert->getName().getPrefix(-1)] = idCert;
}
else
- throw Error("Cannot read certificate from file: " +
- certfilePath.native());
+ BOOST_THROW_EXCEPTION(Error("Cannot read certificate from file: " +
+ certfilePath.native()));
return;
}
@@ -293,14 +293,14 @@
{
// Get trust-anchor.base64-string
if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "base64-string"))
- throw Error("Expect <trust-anchor.base64-string>!");
+ BOOST_THROW_EXCEPTION(Error("Expect <trust-anchor.base64-string>!"));
std::stringstream ss(propertyIt->second.data());
propertyIt++;
// Check other stuff
if (propertyIt != configSection.end())
- throw Error("Expect the end of trust-anchor!");
+ BOOST_THROW_EXCEPTION(Error("Expect the end of trust-anchor!"));
shared_ptr<IdentityCertificate> idCert = io::load<IdentityCertificate>(ss);
@@ -311,14 +311,14 @@
m_anchors[idCert->getName().getPrefix(-1)] = idCert;
}
else
- throw Error("Cannot decode certificate from base64-string");
+ BOOST_THROW_EXCEPTION(Error("Cannot decode certificate from base64-string"));
return;
}
else if (boost::iequals(type, "dir"))
{
if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "dir"))
- throw Error("Expect <trust-anchor.dir>!");
+ BOOST_THROW_EXCEPTION(Error("Expect <trust-anchor.dir>"));
std::string dirString(propertyIt->second.data());
propertyIt++;
@@ -333,7 +333,7 @@
propertyIt++;
if (propertyIt != configSection.end())
- throw Error("Expect the end of trust-anchor!");
+ BOOST_THROW_EXCEPTION(Error("Expect the end of trust-anchor"));
path dirPath = absolute(dirString, path(filename).parent_path());
@@ -344,7 +344,7 @@
return;
}
else
- throw Error("Expect <trust-anchor.refresh>!");
+ BOOST_THROW_EXCEPTION(Error("Expect <trust-anchor.refresh>!"));
}
else
{
@@ -371,7 +371,7 @@
m_shouldValidate = false;
}
else
- throw Error("Unsupported trust-anchor.type: " + type);
+ BOOST_THROW_EXCEPTION(Error("Unsupported trust-anchor.type: " + type));
}
void
@@ -414,7 +414,7 @@
}
catch (boost::bad_lexical_cast&)
{
- throw Error("Bad number: " + refreshString);
+ BOOST_THROW_EXCEPTION(Error("Bad number: " + refreshString));
}
if (number == 0)
@@ -429,7 +429,7 @@
case 's':
return time::duration_cast<time::nanoseconds>(time::seconds(number));
default:
- throw Error(std::string("Wrong time unit: ") + unit);
+ BOOST_THROW_EXCEPTION(Error(std::string("Wrong time unit: ") + unit));
}
}
diff --git a/src/security/validity-period.cpp b/src/security/validity-period.cpp
index 008cd3c..c6f6026 100644
--- a/src/security/validity-period.cpp
+++ b/src/security/validity-period.cpp
@@ -94,23 +94,23 @@
ValidityPeriod::wireDecode(const Block& wire)
{
if (!wire.hasWire()) {
- throw Error("The supplied block does not contain wire format");
+ BOOST_THROW_EXCEPTION(Error("The supplied block does not contain wire format"));
}
m_wire = wire;
m_wire.parse();
if (m_wire.type() != tlv::ValidityPeriod)
- throw Error("Unexpected TLV type when decoding ValidityPeriod");
+ BOOST_THROW_EXCEPTION(Error("Unexpected TLV type when decoding ValidityPeriod"));
if (m_wire.elements_size() != 2)
- throw Error("Does not have two sub-TLVs");
+ BOOST_THROW_EXCEPTION(Error("Does not have two sub-TLVs"));
if (m_wire.elements()[NOT_BEFORE_OFFSET].type() != tlv::NotBefore ||
m_wire.elements()[NOT_BEFORE_OFFSET].value_size() != ISO_DATETIME_SIZE ||
m_wire.elements()[NOT_AFTER_OFFSET].type() != tlv::NotAfter ||
m_wire.elements()[NOT_AFTER_OFFSET].value_size() != ISO_DATETIME_SIZE) {
- throw Error("Invalid NotBefore or NotAfter field");
+ BOOST_THROW_EXCEPTION(Error("Invalid NotBefore or NotAfter field"));
}
try {
@@ -120,7 +120,7 @@
time::fromIsoString(readString(m_wire.elements()[NOT_AFTER_OFFSET])));
}
catch (const std::bad_cast&) {
- throw Error("Invalid date format in NOT-BEFORE or NOT-AFTER field");
+ BOOST_THROW_EXCEPTION(Error("Invalid date format in NOT-BEFORE or NOT-AFTER field"));
}
}
diff --git a/src/selectors.cpp b/src/selectors.cpp
index 6e637fa..7b46b1e 100644
--- a/src/selectors.cpp
+++ b/src/selectors.cpp
@@ -135,7 +135,7 @@
Selectors::wireDecode(const Block& wire)
{
if (wire.type() != tlv::Selectors)
- throw tlv::Error("Unexpected TLV type when decoding Selectors");
+ BOOST_THROW_EXCEPTION(tlv::Error("Unexpected TLV type when decoding Selectors"));
*this = Selectors();
diff --git a/src/signature-info.cpp b/src/signature-info.cpp
index e48482e..d96aab3 100644
--- a/src/signature-info.cpp
+++ b/src/signature-info.cpp
@@ -87,7 +87,7 @@
if (m_hasKeyLocator)
return m_keyLocator;
else
- throw Error("KeyLocator does not exist");
+ BOOST_THROW_EXCEPTION(Error("KeyLocator does not exist"));
}
void
@@ -110,7 +110,7 @@
SignatureInfo::getValidityPeriod() const
{
if (m_otherTlvs.empty() || m_otherTlvs.front().type() != tlv::ValidityPeriod) {
- throw Error("SignatureInfo does not contain the requested ValidityPeriod field");
+ BOOST_THROW_EXCEPTION(Error("SignatureInfo does not contain the requested ValidityPeriod field"));
}
return security::ValidityPeriod(m_otherTlvs.front());
@@ -132,8 +132,8 @@
return *i;
}
- throw Error("(SignatureInfo::getTypeSpecificTlv) Requested a non-existed type [" +
- boost::lexical_cast<std::string>(type) + "] from SignatureInfo");
+ BOOST_THROW_EXCEPTION(Error("(SignatureInfo::getTypeSpecificTlv) Requested a non-existed type [" +
+ boost::lexical_cast<std::string>(type) + "] from SignatureInfo"));
}
template<encoding::Tag TAG>
@@ -184,7 +184,7 @@
SignatureInfo::wireDecode(const Block& wire)
{
if (!wire.hasWire()) {
- throw Error("The supplied block does not contain wire format");
+ BOOST_THROW_EXCEPTION(Error("The supplied block does not contain wire format"));
}
m_hasKeyLocator = false;
@@ -193,7 +193,7 @@
m_wire.parse();
if (m_wire.type() != tlv::SignatureInfo)
- throw tlv::Error("Unexpected TLV type when decoding Name");
+ BOOST_THROW_EXCEPTION(tlv::Error("Unexpected TLV type when decoding Name"));
Block::element_const_iterator it = m_wire.elements_begin();
@@ -203,7 +203,8 @@
it++;
}
else
- throw Error("SignatureInfo does not have sub-TLV or the first sub-TLV is not SignatureType");
+ BOOST_THROW_EXCEPTION(Error("SignatureInfo does not have sub-TLV or the first sub-TLV is not "
+ "SignatureType"));
// the second block could be KeyLocator
if (it != m_wire.elements_end() && it->type() == tlv::KeyLocator) {
diff --git a/src/signature.cpp b/src/signature.cpp
index 2152dd0..10b2218 100644
--- a/src/signature.cpp
+++ b/src/signature.cpp
@@ -50,7 +50,7 @@
Signature::setValue(const Block& value)
{
if (value.type() != tlv::SignatureValue) {
- throw Error("The supplied block is not SignatureValue");
+ BOOST_THROW_EXCEPTION(Error("The supplied block is not SignatureValue"));
}
m_value = value;
}
diff --git a/src/transport/stream-transport.hpp b/src/transport/stream-transport.hpp
index d7f2e49..99dc510 100644
--- a/src/transport/stream-transport.hpp
+++ b/src/transport/stream-transport.hpp
@@ -68,7 +68,7 @@
// may need to throw exception
m_transport.m_isConnected = false;
m_transport.close();
- throw Transport::Error(error, "error while connecting to the forwarder");
+ BOOST_THROW_EXCEPTION(Transport::Error(error, "error while connecting to the forwarder"));
}
}
@@ -79,7 +79,7 @@
return;
m_transport.close();
- throw Transport::Error(error, "error while connecting to the forwarder");
+ BOOST_THROW_EXCEPTION(Transport::Error(error, "error while connecting to the forwarder"));
}
void
@@ -192,7 +192,7 @@
}
m_transport.close();
- throw Transport::Error(error, "error while sending data to socket");
+ BOOST_THROW_EXCEPTION(Transport::Error(error, "error while sending data to socket"));
}
m_transmissionQueue.erase(queueItem);
@@ -231,7 +231,7 @@
}
m_transport.close();
- throw Transport::Error(error, "error while receiving data from socket");
+ BOOST_THROW_EXCEPTION(Transport::Error(error, "error while receiving data from socket"));
}
m_inputBufferSize += nBytesRecvd;
@@ -242,8 +242,9 @@
if (!hasProcessedSome && m_inputBufferSize == MAX_NDN_PACKET_SIZE && offset == 0)
{
m_transport.close();
- throw Transport::Error(boost::system::error_code(),
- "input buffer full, but a valid TLV cannot be decoded");
+ BOOST_THROW_EXCEPTION(Transport::Error(boost::system::error_code(),
+ "input buffer full, but a valid TLV cannot be "
+ "decoded"));
}
if (offset > 0)
@@ -300,14 +301,14 @@
if (error == boost::system::errc::operation_canceled)
return;
- throw Transport::Error(error, "Error during resolution of host or port");
+ BOOST_THROW_EXCEPTION(Transport::Error(error, "Error during resolution of host or port"));
}
typename Protocol::resolver::iterator end;
if (endpoint == end)
{
this->m_transport.close();
- throw Transport::Error(error, "Unable to resolve because host or port");
+ BOOST_THROW_EXCEPTION(Transport::Error(error, "Unable to resolve because host or port"));
}
this->m_socket.async_connect(*endpoint,
diff --git a/src/transport/tcp-transport.cpp b/src/transport/tcp-transport.cpp
index c43790f..afde1e0 100644
--- a/src/transport/tcp-transport.cpp
+++ b/src/transport/tcp-transport.cpp
@@ -57,8 +57,8 @@
const std::string scheme = uri.getScheme();
if (scheme != "tcp" && scheme != "tcp4" && scheme != "tcp6") {
- throw Transport::Error("Cannot create TcpTransport from \"" +
- scheme + "\" URI");
+ BOOST_THROW_EXCEPTION(Transport::Error("Cannot create TcpTransport from \"" +
+ scheme + "\" URI"));
}
if (!uri.getHost().empty()) {
@@ -70,7 +70,7 @@
}
}
catch (const util::FaceUri::Error& error) {
- throw ConfigFile::Error(error.what());
+ BOOST_THROW_EXCEPTION(ConfigFile::Error(error.what()));
}
return {host, port};
diff --git a/src/transport/unix-transport.cpp b/src/transport/unix-transport.cpp
index df505d7..3464d79 100644
--- a/src/transport/unix-transport.cpp
+++ b/src/transport/unix-transport.cpp
@@ -49,8 +49,8 @@
if (uri.getScheme() != "unix")
{
- throw Transport::Error("Cannot create UnixTransport from \"" +
- uri.getScheme() + "\" URI");
+ BOOST_THROW_EXCEPTION(Transport::Error("Cannot create UnixTransport from \"" +
+ uri.getScheme() + "\" URI"));
}
if (!uri.getPath().empty())
@@ -64,11 +64,11 @@
}
catch (const boost::property_tree::ptree_bad_data& error)
{
- throw ConfigFile::Error(error.what());
+ BOOST_THROW_EXCEPTION(ConfigFile::Error(error.what()));
}
catch (const util::FaceUri::Error& error)
{
- throw ConfigFile::Error(error.what());
+ BOOST_THROW_EXCEPTION(ConfigFile::Error(error.what()));
}
// Assume the default nfd.sock location.
diff --git a/src/util/config-file.cpp b/src/util/config-file.cpp
index a68939d..ebf2a7a 100644
--- a/src/util/config-file.cpp
+++ b/src/util/config-file.cpp
@@ -123,11 +123,11 @@
{
if (m_path.empty())
{
- throw Error("Failed to locate configuration file for parsing");
+ BOOST_THROW_EXCEPTION(Error("Failed to locate configuration file for parsing"));
}
else if (!m_input.is_open() && !open())
{
- throw Error("Failed to open configuration file for parsing");
+ BOOST_THROW_EXCEPTION(Error("Failed to open configuration file for parsing"));
}
try
@@ -140,7 +140,7 @@
msg << "Failed to parse configuration file";
msg << " " << m_path;
msg << " " << error.message() << " line " << error.line();
- throw Error(msg.str());
+ BOOST_THROW_EXCEPTION(Error(msg.str()));
}
return m_config;
}
diff --git a/src/util/digest.cpp b/src/util/digest.cpp
index d5bb312..23af4c9 100644
--- a/src/util/digest.cpp
+++ b/src/util/digest.cpp
@@ -126,7 +126,7 @@
{
// cannot update Digest when it has been finalized
if (m_isFinalized)
- throw Error("Digest has been already finalized");
+ BOOST_THROW_EXCEPTION(Error("Digest has been already finalized"));
m_hash.Update(buffer, size);
diff --git a/src/util/dns.cpp b/src/util/dns.cpp
index 03bf9f9..7c992ff 100644
--- a/src/util/dns.cpp
+++ b/src/util/dns.cpp
@@ -151,7 +151,7 @@
return EndPoint(*remoteEndpoint).address();
}
}
- throw Error("No endpoint matching the specified address selector found");
+ BOOST_THROW_EXCEPTION(Error("No endpoint matching the specified address selector found"));
}
} // namespace dns
diff --git a/src/util/face-uri.cpp b/src/util/face-uri.cpp
index ff5669b..f23ae8c 100644
--- a/src/util/face-uri.cpp
+++ b/src/util/face-uri.cpp
@@ -48,14 +48,14 @@
FaceUri::FaceUri(const std::string& uri)
{
if (!parse(uri)) {
- throw Error("Malformed URI: " + uri);
+ BOOST_THROW_EXCEPTION(Error("Malformed URI: " + uri));
}
}
FaceUri::FaceUri(const char* uri)
{
if (!parse(uri)) {
- throw Error("Malformed URI: " + std::string(uri));
+ BOOST_THROW_EXCEPTION(Error("Malformed URI: " + std::string(uri)));
}
}
diff --git a/src/util/in-memory-storage.cpp b/src/util/in-memory-storage.cpp
index 9c3146f..5001e97 100644
--- a/src/util/in-memory-storage.cpp
+++ b/src/util/in-memory-storage.cpp
@@ -125,7 +125,7 @@
ssize_t nAllowedFailures = size() - m_capacity;
while (size() > m_capacity) {
if (!evictItem() && --nAllowedFailures < 0) {
- throw Error();
+ BOOST_THROW_EXCEPTION(Error());
}
}
}
diff --git a/src/util/io.hpp b/src/util/io.hpp
index f49d712..f751bc6 100644
--- a/src/util/io.hpp
+++ b/src/util/io.hpp
@@ -148,15 +148,15 @@
}
catch (TypeError& e)
{
- throw Error(e.what());
+ BOOST_THROW_EXCEPTION(Error(e.what()));
}
catch (CryptoPP::Exception& e)
{
- throw Error(e.what());
+ BOOST_THROW_EXCEPTION(Error(e.what()));
}
catch (tlv::Error& e)
{
- throw Error(e.what());
+ BOOST_THROW_EXCEPTION(Error(e.what()));
}
}
diff --git a/src/util/network-monitor.cpp b/src/util/network-monitor.cpp
index 5513d0d..8f7b1f9 100644
--- a/src/util/network-monitor.cpp
+++ b/src/util/network-monitor.cpp
@@ -165,7 +165,8 @@
{
int fd = ::socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
if (fd < 0)
- throw Error(std::string("Cannot create netlink socket (") + std::strerror(errno) + ")");
+ BOOST_THROW_EXCEPTION(Error(std::string("Cannot create netlink socket (") +
+ std::strerror(errno) + ")"));
sockaddr_nl addr{};
addr.nl_family = AF_NETLINK;
@@ -174,7 +175,8 @@
RTMGRP_IPV6_IFADDR | RTMGRP_IPV6_ROUTE;
if (::bind(fd, reinterpret_cast<sockaddr*>(&addr), sizeof(addr)) == -1) {
- throw Error(std::string("Cannot bind on netlink socket (") + std::strerror(errno) + ")");
+ BOOST_THROW_EXCEPTION(Error(std::string("Cannot bind on netlink socket (") +
+ std::strerror(errno) + ")"));
}
m_socket.assign(fd);
@@ -239,7 +241,7 @@
NetworkMonitor::NetworkMonitor(boost::asio::io_service&)
{
- throw Error("Network monitoring is not supported on this platform");
+ BOOST_THROW_EXCEPTION(Error("Network monitoring is not supported on this platform"));
}
NetworkMonitor::~NetworkMonitor()
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>
diff --git a/src/util/sqlite3-statement.cpp b/src/util/sqlite3-statement.cpp
index 243088b..f1871db 100644
--- a/src/util/sqlite3-statement.cpp
+++ b/src/util/sqlite3-statement.cpp
@@ -35,7 +35,7 @@
{
int res = sqlite3_prepare_v2(database, statement.c_str(), -1, &m_stmt, nullptr);
if (res != SQLITE_OK)
- throw std::domain_error("bad SQL statement: " + statement);
+ BOOST_THROW_EXCEPTION(std::domain_error("bad SQL statement: " + statement));
}
int
diff --git a/src/util/string-helper.cpp b/src/util/string-helper.cpp
index fc0e1a1..16064b0 100644
--- a/src/util/string-helper.cpp
+++ b/src/util/string-helper.cpp
@@ -89,7 +89,8 @@
fromHex(const std::string& hexString)
{
if (hexString.size() % 2 != 0) {
- throw StringHelperError("Invalid number of characters in the supplied hex string");
+ BOOST_THROW_EXCEPTION(StringHelperError("Invalid number of characters in the supplied hex "
+ "string"));
}
using namespace CryptoPP;
@@ -99,7 +100,7 @@
shared_ptr<const Buffer> buffer = os.buf();
if (buffer->size() * 2 != hexString.size()) {
- throw StringHelperError("The supplied hex string contains non-hex characters");
+ BOOST_THROW_EXCEPTION(StringHelperError("The supplied hex string contains non-hex characters"));
}
return buffer;
diff --git a/tests/unit-tests/security/dummy-keychain.cpp b/tests/unit-tests/security/dummy-keychain.cpp
index 58f3b9e..c7e7a10 100644
--- a/tests/unit-tests/security/dummy-keychain.cpp
+++ b/tests/unit-tests/security/dummy-keychain.cpp
@@ -333,14 +333,14 @@
DummyTpm::decryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName,
bool isSymmetric)
{
- throw Error("Not supported");
+ BOOST_THROW_EXCEPTION(Error("Not supported"));
}
ConstBufferPtr
DummyTpm::encryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName,
bool isSymmetric)
{
- throw Error("Not supported");
+ BOOST_THROW_EXCEPTION(Error("Not supported"));
}
void
@@ -369,7 +369,7 @@
ConstBufferPtr
DummyTpm::exportPrivateKeyPkcs8FromTpm(const Name& keyName)
{
- throw Error("Not supported");
+ BOOST_THROW_EXCEPTION(Error("Not supported"));
}
bool
diff --git a/tests/unit-tests/util/signal.t.cpp b/tests/unit-tests/util/signal.t.cpp
index 41750c2..153ad91 100644
--- a/tests/unit-tests/util/signal.t.cpp
+++ b/tests/unit-tests/util/signal.t.cpp
@@ -405,14 +405,14 @@
{
SignalOwner0 so;
- struct HandlerError
+ struct HandlerError : public std::exception
{
};
int hit = 0;
so.sig.connect([&] {
++hit;
- throw HandlerError();
+ BOOST_THROW_EXCEPTION(HandlerError());
});
BOOST_CHECK_THROW(so.emitSignal(sig), HandlerError);
diff --git a/tests/unit-tests/util/simple-notification.hpp b/tests/unit-tests/util/simple-notification.hpp
index 1d22a2a..66e4641 100644
--- a/tests/unit-tests/util/simple-notification.hpp
+++ b/tests/unit-tests/util/simple-notification.hpp
@@ -77,7 +77,7 @@
// error for testing
if (!m_message.empty() && m_message[0] == '\x07')
- throw tlv::Error("0x07 error");
+ BOOST_THROW_EXCEPTION(tlv::Error("0x07 error"));
}
public: