Replace all uses of BOOST_THROW_EXCEPTION with NDN_THROW
Refs: #4834
Change-Id: If2455e1830f310beea434ffb455d960e11c4c2ed
diff --git a/core/common.hpp b/core/common.hpp
index 2678a17..93c2933 100644
--- a/core/common.hpp
+++ b/core/common.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -65,6 +65,7 @@
#include <ndn-cxx/lp/nack.hpp>
#include <ndn-cxx/net/face-uri.hpp>
#include <ndn-cxx/util/backports.hpp>
+#include <ndn-cxx/util/exception.hpp>
#include <ndn-cxx/util/signal.hpp>
#include <boost/asio.hpp>
@@ -72,7 +73,6 @@
#include <boost/lexical_cast.hpp>
#include <boost/noncopyable.hpp>
#include <boost/property_tree/ptree.hpp>
-#include <boost/throw_exception.hpp>
namespace nfd {
diff --git a/core/config-file.cpp b/core/config-file.cpp
index 548d351..accfe72 100644
--- a/core/config-file.cpp
+++ b/core/config-file.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -26,6 +26,7 @@
#include "config-file.hpp"
#include <boost/property_tree/info_parser.hpp>
+
#include <fstream>
#include <sstream>
@@ -42,8 +43,8 @@
const ConfigSection& section,
bool isDryRun)
{
- BOOST_THROW_EXCEPTION(Error("Error processing configuration file " + filename +
- ": no module subscribed for section \"" + sectionName + "\""));
+ NDN_THROW(Error("Error processing configuration file " + filename +
+ ": no module subscribed for section '" + sectionName + "'"));
}
void
@@ -68,8 +69,8 @@
return false;
}
- BOOST_THROW_EXCEPTION(Error("Invalid value \"" + value + "\" for option \"" +
- key + "\" in \"" + sectionName + "\" section"));
+ NDN_THROW(Error("Invalid value '" + value + "' for option '" +
+ key + "' in section '" + sectionName + "'"));
}
void
@@ -84,7 +85,7 @@
{
std::ifstream inputFile(filename);
if (!inputFile.good() || !inputFile.is_open()) {
- BOOST_THROW_EXCEPTION(Error("Failed to read configuration file " + filename));
+ NDN_THROW(Error("Failed to read configuration file " + filename));
}
parse(inputFile, isDryRun, filename);
inputFile.close();
@@ -104,8 +105,8 @@
boost::property_tree::read_info(input, m_global);
}
catch (const boost::property_tree::info_parser_error& error) {
- BOOST_THROW_EXCEPTION(Error("Failed to parse configuration file " + filename +
- ": " + error.message() + " on line " + to_string(error.line())));
+ NDN_THROW(Error("Failed to parse configuration file " + filename +
+ ": " + error.message() + " on line " + to_string(error.line())));
}
process(isDryRun, filename);
diff --git a/core/config-file.hpp b/core/config-file.hpp
index d51b1e9..819b9b4 100644
--- a/core/config-file.hpp
+++ b/core/config-file.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -60,11 +60,7 @@
class Error : public std::runtime_error
{
public:
- explicit
- Error(const std::string& what)
- : std::runtime_error(what)
- {
- }
+ using std::runtime_error::runtime_error;
};
explicit
@@ -115,8 +111,8 @@
if (value) {
return *value;
}
- BOOST_THROW_EXCEPTION(Error("Invalid value \"" + node.get_value<std::string>() +
- "\" for option \"" + key + "\" in \"" + sectionName + "\" section"));
+ NDN_THROW(Error("Invalid value '" + node.get_value<std::string>() +
+ "' for option '" + key + "' in section '" + sectionName + "'"));
}
template <typename T>
diff --git a/core/log-config-section.cpp b/core/log-config-section.cpp
index 6f6f0ab..9d8168c 100644
--- a/core/log-config-section.cpp
+++ b/core/log-config-section.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -37,8 +37,8 @@
try {
return ndn::util::parseLogLevel(item.get_value<std::string>());
}
- catch (const std::invalid_argument& e) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("Invalid setting for log." + key + ": " + e.what()));
+ catch (const std::invalid_argument&) {
+ NDN_THROW_NESTED(ConfigFile::Error("Invalid log level for '" + key + "' in section 'log'"));
}
}
diff --git a/core/network-predicate.cpp b/core/network-predicate.cpp
index d10a5e3..43a0d40 100644
--- a/core/network-predicate.cpp
+++ b/core/network-predicate.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -47,7 +47,9 @@
}
void
-NetworkPredicateBase::parseList(std::set<std::string>& set, const boost::property_tree::ptree& list, const std::string& section)
+NetworkPredicateBase::parseList(std::set<std::string>& set,
+ const boost::property_tree::ptree& list,
+ const std::string& section)
{
set.clear();
@@ -58,12 +60,14 @@
}
else {
if (!isRuleSupported(item.first)) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("Unrecognized rule \"" + item.first + "\" in \"" + section + "\" section"));
+ NDN_THROW(ConfigFile::Error("Unrecognized rule '" + item.first +
+ "' in section '" + section + "'"));
}
auto value = item.second.get_value<std::string>();
if (!isRuleValid(item.first, value)) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("Malformed " + item.first + " \"" + value + "\" in \"" + section + "\" section"));
+ NDN_THROW(ConfigFile::Error("Malformed " + item.first + " '" + value +
+ "' in section '" + section + "'"));
}
set.insert(value);
}
@@ -71,7 +75,8 @@
}
void
-NetworkPredicateBase::parseList(std::set<std::string>& set, std::initializer_list<std::pair<std::string, std::string>> list)
+NetworkPredicateBase::parseList(std::set<std::string>& set,
+ std::initializer_list<std::pair<std::string, std::string>> list)
{
set.clear();
@@ -82,11 +87,11 @@
}
else {
if (!isRuleSupported(item.first)) {
- BOOST_THROW_EXCEPTION(std::runtime_error("Unrecognized rule \"" + item.first + "\""));
+ NDN_THROW(std::runtime_error("Unrecognized rule '" + item.first + "'"));
}
if (!isRuleValid(item.first, item.second)) {
- BOOST_THROW_EXCEPTION(std::runtime_error("Malformed " + item.first + " \"" + item.second + "\""));
+ NDN_THROW(std::runtime_error("Malformed " + item.first + " '" + item.second + "'"));
}
set.insert(item.second);
}
@@ -135,7 +140,7 @@
return Network::isValidCidr(value);
}
else {
- BOOST_THROW_EXCEPTION(std::logic_error("Only supported rules are expected"));
+ NDN_THROW(std::logic_error("Only supported rules are expected"));
}
}
@@ -153,7 +158,7 @@
return Network::isValidCidr(value);
}
else {
- BOOST_THROW_EXCEPTION(std::logic_error("Only supported rules are expected"));
+ NDN_THROW(std::logic_error("Only supported rules are expected"));
}
}
diff --git a/core/privilege-helper.hpp b/core/privilege-helper.hpp
index bbf08e2..0379b2f 100644
--- a/core/privilege-helper.hpp
+++ b/core/privilege-helper.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -38,7 +38,7 @@
/** \brief represents a serious seteuid/gid failure
*
* This should only be caught by main as part of a graceful program termination.
- * \note This is not an std::exception and BOOST_THROW_EXCEPTION should not be used.
+ * \note This is not an std::exception and NDN_THROW should not be used.
*/
class Error
{
diff --git a/daemon/face/ethernet-channel.cpp b/daemon/face/ethernet-channel.cpp
index 691b40b..21949b3 100644
--- a/daemon/face/ethernet-channel.cpp
+++ b/daemon/face/ethernet-channel.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -89,7 +89,7 @@
m_socket.assign(m_pcap.getFd());
}
catch (const PcapHelper::Error& e) {
- BOOST_THROW_EXCEPTION(Error(e.what()));
+ NDN_THROW_NESTED(Error(e.what()));
}
updateFilter();
diff --git a/daemon/face/ethernet-factory.cpp b/daemon/face/ethernet-factory.cpp
index 7603343..4d4d295 100644
--- a/daemon/face/ethernet-factory.cpp
+++ b/daemon/face/ethernet-factory.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -96,12 +96,12 @@
const std::string& valueStr = value.get_value<std::string>();
mcastConfig.group = ethernet::Address::fromString(valueStr);
if (mcastConfig.group.isNull()) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("face_system.ether.mcast_group: '" +
- valueStr + "' cannot be parsed as an Ethernet address"));
+ NDN_THROW(ConfigFile::Error("face_system.ether.mcast_group: '" +
+ valueStr + "' cannot be parsed as an Ethernet address"));
}
else if (!mcastConfig.group.isMulticast()) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("face_system.ether.mcast_group: '" +
- valueStr + "' is not a multicast address"));
+ NDN_THROW(ConfigFile::Error("face_system.ether.mcast_group: '" +
+ valueStr + "' is not a multicast address"));
}
}
else if (key == "mcast_ad_hoc") {
@@ -115,7 +115,7 @@
mcastConfig.netifPredicate.parseBlacklist(value);
}
else {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("Unrecognized option face_system.ether." + key));
+ NDN_THROW(ConfigFile::Error("Unrecognized option face_system.ether." + key));
}
}
}
diff --git a/daemon/face/ethernet-transport.cpp b/daemon/face/ethernet-transport.cpp
index 412bcba..ee7193b 100644
--- a/daemon/face/ethernet-transport.cpp
+++ b/daemon/face/ethernet-transport.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -55,7 +55,7 @@
m_socket.assign(m_pcap.getFd());
}
catch (const PcapHelper::Error& e) {
- BOOST_THROW_EXCEPTION(Error(e.what()));
+ NDN_THROW_NESTED(Error(e.what()));
}
m_netifStateConn = localEndpoint.onStateChanged.connect(
diff --git a/daemon/face/face-system.cpp b/daemon/face/face-system.cpp
index 79880da..21685f3 100644
--- a/daemon/face/face-system.cpp
+++ b/daemon/face/face-system.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -110,7 +110,7 @@
context.generalConfig.wantCongestionMarking = ConfigFile::parseYesNo(pair, "face_system.general");
}
else {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("Unrecognized option face_system.general." + key));
+ NDN_THROW(ConfigFile::Error("Unrecognized option face_system.general." + key));
}
}
}
@@ -150,7 +150,7 @@
// const ConfigSection& subSection = pair.second;
if (!seenSections.insert(sectionName).second) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("Duplicate section face_system." + sectionName));
+ NDN_THROW(ConfigFile::Error("Duplicate section face_system." + sectionName));
}
if (sectionName == SECTION_GENERAL || sectionName == SECTION_NETDEVBOUND ||
@@ -158,7 +158,7 @@
continue;
}
- BOOST_THROW_EXCEPTION(ConfigFile::Error("Unrecognized option face_system." + sectionName));
+ NDN_THROW(ConfigFile::Error("Unrecognized option face_system." + sectionName));
}
}
diff --git a/daemon/face/lp-reliability.cpp b/daemon/face/lp-reliability.cpp
index 7b248fb..d46356b 100644
--- a/daemon/face/lp-reliability.cpp
+++ b/daemon/face/lp-reliability.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -188,7 +188,7 @@
lp::Sequence txSeq = ++m_lastTxSeqNo;
frag.set<lp::TxSequenceField>(txSeq);
if (m_unackedFrags.size() > 0 && m_lastTxSeqNo == m_firstUnackedFrag->first) {
- BOOST_THROW_EXCEPTION(std::length_error("TxSequence range exceeded"));
+ NDN_THROW(std::length_error("TxSequence range exceeded"));
}
return m_lastTxSeqNo;
}
diff --git a/daemon/face/multicast-ethernet-transport.cpp b/daemon/face/multicast-ethernet-transport.cpp
index 91c25d4..2afb793 100644
--- a/daemon/face/multicast-ethernet-transport.cpp
+++ b/daemon/face/multicast-ethernet-transport.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -144,7 +144,7 @@
NFD_LOG_FACE_WARN("ioctl(SIOCADDMULTI) failed: " << std::strerror(errno));
#endif
- BOOST_THROW_EXCEPTION(Error("Failed to join multicast group"));
+ NDN_THROW(Error("Failed to join multicast group"));
}
} // namespace face
diff --git a/daemon/face/multicast-udp-transport.cpp b/daemon/face/multicast-udp-transport.cpp
index db12128..6e99a1c 100644
--- a/daemon/face/multicast-udp-transport.cpp
+++ b/daemon/face/multicast-udp-transport.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -124,8 +124,7 @@
#if defined(__linux__) && !defined(__ANDROID__)
PrivilegeHelper::runElevated([=] {
if (::setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, ifname.data(), ifname.size() + 1) < 0) {
- BOOST_THROW_EXCEPTION(MulticastUdpTransport::Error("Cannot bind multicast rx socket to " +
- ifname + ": " + std::strerror(errno)));
+ NDN_THROW_ERRNO(MulticastUdpTransport::Error("Cannot bind multicast rx socket to " + ifname));
}
});
#endif
diff --git a/daemon/face/netdev-bound.cpp b/daemon/face/netdev-bound.cpp
index a47bd43..5ed975d 100644
--- a/daemon/face/netdev-bound.cpp
+++ b/daemon/face/netdev-bound.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -53,8 +53,7 @@
rules.push_back(parseRule(ruleIndex++, value));
}
else {
- BOOST_THROW_EXCEPTION(ConfigFile::Error(
- "Unrecognized option face_system.netdev_bound." + key));
+ NDN_THROW(ConfigFile::Error("Unrecognized option face_system.netdev_bound." + key));
}
}
}
@@ -70,8 +69,8 @@
for (const FaceUri& remote : rule.remotes) {
std::string devScheme = remote.getScheme() + "+dev";
if (!m_faceSystem.hasFactoryForScheme(devScheme)) {
- BOOST_THROW_EXCEPTION(RuleParseError(
- i, "scheme " + devScheme + " for " + remote.toString() + " is unavailable"));
+ NDN_THROW(RuleParseError(i, "scheme '" + devScheme + "' for " +
+ remote.toString() + " is unavailable"));
}
}
}
@@ -102,44 +101,44 @@
try {
rule.remotes.emplace_back(value.get_value<std::string>());
}
- catch (const FaceUri::Error& ex) {
- BOOST_THROW_EXCEPTION(RuleParseError(index, "invalid remote FaceUri", ex.what()));
+ catch (const FaceUri::Error&) {
+ NDN_THROW_NESTED(RuleParseError(index, "invalid remote FaceUri"));
}
if (!rule.remotes.back().isCanonical()) {
- BOOST_THROW_EXCEPTION(RuleParseError(index, "remote FaceUri is not canonical"));
+ NDN_THROW(RuleParseError(index, "remote FaceUri is not canonical"));
}
}
else if (key == "whitelist") {
if (hasWhitelist) {
- BOOST_THROW_EXCEPTION(RuleParseError(index, "duplicate whitelist"));
+ NDN_THROW(RuleParseError(index, "duplicate whitelist"));
}
try {
rule.netifPredicate.parseWhitelist(value);
}
- catch (const ConfigFile::Error& ex) {
- BOOST_THROW_EXCEPTION(RuleParseError(index, "invalid whitelist", ex.what()));
+ catch (const ConfigFile::Error&) {
+ NDN_THROW_NESTED(RuleParseError(index, "invalid whitelist"));
}
hasWhitelist = true;
}
else if (key == "blacklist") {
if (hasBlacklist) {
- BOOST_THROW_EXCEPTION(RuleParseError(index, "duplicate blacklist"));
+ NDN_THROW(RuleParseError(index, "duplicate blacklist"));
}
try {
rule.netifPredicate.parseBlacklist(value);
}
- catch (const ConfigFile::Error& ex) {
- BOOST_THROW_EXCEPTION(RuleParseError(index, "invalid blacklist", ex.what()));
+ catch (const ConfigFile::Error&) {
+ NDN_THROW_NESTED(RuleParseError(index, "invalid blacklist"));
}
hasBlacklist = true;
}
else {
- BOOST_THROW_EXCEPTION(RuleParseError(index, "unrecognized option " + key));
+ NDN_THROW(RuleParseError(index, "unrecognized option " + key));
}
}
if (rule.remotes.empty()) {
- BOOST_THROW_EXCEPTION(RuleParseError(index, "remote FaceUri is missing"));
+ NDN_THROW(RuleParseError(index, "remote FaceUri is missing"));
}
///\todo #3521 for each remote, check that there is a factory providing scheme+dev scheme
diff --git a/daemon/face/netdev-bound.hpp b/daemon/face/netdev-bound.hpp
index 17a6ce8..6297afd 100644
--- a/daemon/face/netdev-bound.hpp
+++ b/daemon/face/netdev-bound.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -48,11 +48,6 @@
{
}
- RuleParseError(int index, std::string msg, const char* innerMsg)
- : RuleParseError(index, msg + " - " + innerMsg)
- {
- }
-
public:
int index;
std::string msg;
diff --git a/daemon/face/pcap-helper.cpp b/daemon/face/pcap-helper.cpp
index 072f75e..4b474e6 100644
--- a/daemon/face/pcap-helper.cpp
+++ b/daemon/face/pcap-helper.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -41,14 +41,14 @@
char errbuf[PCAP_ERRBUF_SIZE] = {};
m_pcap = pcap_create(interfaceName.data(), errbuf);
if (!m_pcap)
- BOOST_THROW_EXCEPTION(Error("pcap_create: " + std::string(errbuf)));
+ NDN_THROW(Error("pcap_create: " + std::string(errbuf)));
// Enable "immediate mode", effectively disabling any read buffering in the kernel.
// This corresponds to the BIOCIMMEDIATE ioctl on BSD-like systems (including macOS)
// where libpcap uses a BPF device. On Linux this forces libpcap not to use TPACKET_V3,
// even if the kernel supports it, thus preventing bug #1511.
if (pcap_set_immediate_mode(m_pcap, 1) < 0)
- BOOST_THROW_EXCEPTION(Error("pcap_set_immediate_mode failed"));
+ NDN_THROW(Error("pcap_set_immediate_mode failed"));
}
PcapHelper::~PcapHelper()
@@ -61,13 +61,13 @@
{
int ret = pcap_activate(m_pcap);
if (ret < 0)
- BOOST_THROW_EXCEPTION(Error("pcap_activate: " + std::string(pcap_statustostr(ret))));
+ NDN_THROW(Error("pcap_activate: " + std::string(pcap_statustostr(ret))));
if (pcap_set_datalink(m_pcap, dlt) < 0)
- BOOST_THROW_EXCEPTION(Error("pcap_set_datalink: " + getLastError()));
+ NDN_THROW(Error("pcap_set_datalink: " + getLastError()));
if (pcap_setdirection(m_pcap, PCAP_D_IN) < 0)
- BOOST_THROW_EXCEPTION(Error("pcap_setdirection: " + getLastError()));
+ NDN_THROW(Error("pcap_setdirection: " + getLastError()));
}
void
@@ -84,7 +84,7 @@
{
int fd = pcap_get_selectable_fd(m_pcap);
if (fd < 0)
- BOOST_THROW_EXCEPTION(Error("pcap_get_selectable_fd failed"));
+ NDN_THROW(Error("pcap_get_selectable_fd failed"));
// we need to duplicate the fd, otherwise both pcap_close() and the
// caller may attempt to close the same fd and one of them will fail
@@ -102,7 +102,7 @@
{
pcap_stat ps{};
if (pcap_stats(m_pcap, &ps) < 0)
- BOOST_THROW_EXCEPTION(Error("pcap_stats: " + getLastError()));
+ NDN_THROW(Error("pcap_stats: " + getLastError()));
return ps.ps_drop;
}
@@ -112,12 +112,12 @@
{
bpf_program prog;
if (pcap_compile(m_pcap, &prog, filter, 1, PCAP_NETMASK_UNKNOWN) < 0)
- BOOST_THROW_EXCEPTION(Error("pcap_compile: " + getLastError()));
+ NDN_THROW(Error("pcap_compile: " + getLastError()));
int ret = pcap_setfilter(m_pcap, &prog);
pcap_freecode(&prog);
if (ret < 0)
- BOOST_THROW_EXCEPTION(Error("pcap_setfilter: " + getLastError()));
+ NDN_THROW(Error("pcap_setfilter: " + getLastError()));
}
std::tuple<const uint8_t*, size_t, std::string>
diff --git a/daemon/face/protocol-factory.cpp b/daemon/face/protocol-factory.cpp
index cdb6cb1..5acb18f 100644
--- a/daemon/face/protocol-factory.cpp
+++ b/daemon/face/protocol-factory.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -114,7 +114,7 @@
ProtocolFactory::doCreateNetdevBoundFace(const FaceUri&,
const shared_ptr<const ndn::net::NetworkInterface>&)
{
- BOOST_THROW_EXCEPTION(Error("This protocol factory does not support netdev-bound faces"));
+ NDN_THROW(Error("This protocol factory does not support netdev-bound faces"));
}
std::vector<shared_ptr<const Channel>>
diff --git a/daemon/face/tcp-factory.cpp b/daemon/face/tcp-factory.cpp
index d77b639..f45d786 100644
--- a/daemon/face/tcp-factory.cpp
+++ b/daemon/face/tcp-factory.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -94,12 +94,12 @@
local.parseBlacklist(localPair.second);
}
else {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("Unrecognized option face_system.tcp.local." + localKey));
+ NDN_THROW(ConfigFile::Error("Unrecognized option face_system.tcp.local." + localKey));
}
}
}
else {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("Unrecognized option face_system.tcp." + key));
+ NDN_THROW(ConfigFile::Error("Unrecognized option face_system.tcp." + key));
}
}
if (!isLocalConfigured) {
@@ -107,7 +107,7 @@
}
if (!enableV4 && !enableV6) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error(
+ NDN_THROW(ConfigFile::Error(
"IPv4 and IPv6 TCP channels have been disabled. Remove face_system.tcp section to disable "
"TCP channels or enable at least one channel type."));
}
diff --git a/daemon/face/transport.cpp b/daemon/face/transport.cpp
index c08990a..e93480f 100644
--- a/daemon/face/transport.cpp
+++ b/daemon/face/transport.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -201,7 +201,7 @@
}
if (!isValid) {
- BOOST_THROW_EXCEPTION(std::runtime_error("invalid state transition"));
+ NDN_THROW(std::runtime_error("Invalid state transition"));
}
NFD_LOG_FACE_INFO("setState " << m_state << " -> " << newState);
diff --git a/daemon/face/udp-factory.cpp b/daemon/face/udp-factory.cpp
index 6c261fb..6730389 100644
--- a/daemon/face/udp-factory.cpp
+++ b/daemon/face/udp-factory.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -124,12 +124,12 @@
boost::system::error_code ec;
mcastConfig.group.address(ip::address_v4::from_string(valueStr, ec));
if (ec) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("face_system.udp.mcast_group: '" +
- valueStr + "' cannot be parsed as an IPv4 address"));
+ NDN_THROW(ConfigFile::Error("face_system.udp.mcast_group: '" +
+ valueStr + "' cannot be parsed as an IPv4 address"));
}
else if (!mcastConfig.group.address().is_multicast()) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("face_system.udp.mcast_group: '" +
- valueStr + "' is not a multicast address"));
+ NDN_THROW(ConfigFile::Error("face_system.udp.mcast_group: '" +
+ valueStr + "' is not a multicast address"));
}
}
else if (key == "mcast_port") {
@@ -140,12 +140,12 @@
boost::system::error_code ec;
mcastConfig.groupV6.address(ip::address_v6::from_string(valueStr, ec));
if (ec) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("face_system.udp.mcast_group_v6: '" +
- valueStr + "' cannot be parsed as an IPv6 address"));
+ NDN_THROW(ConfigFile::Error("face_system.udp.mcast_group_v6: '" +
+ valueStr + "' cannot be parsed as an IPv6 address"));
}
else if (!mcastConfig.groupV6.address().is_multicast()) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("face_system.udp.mcast_group_v6: '" +
- valueStr + "' is not a multicast address"));
+ NDN_THROW(ConfigFile::Error("face_system.udp.mcast_group_v6: '" +
+ valueStr + "' is not a multicast address"));
}
}
else if (key == "mcast_port_v6") {
@@ -162,12 +162,12 @@
mcastConfig.netifPredicate.parseBlacklist(value);
}
else {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("Unrecognized option face_system.udp." + key));
+ NDN_THROW(ConfigFile::Error("Unrecognized option face_system.udp." + key));
}
}
if (!enableV4 && !enableV6 && !mcastConfig.isEnabled) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error(
+ NDN_THROW(ConfigFile::Error(
"IPv4 and IPv6 UDP channels and UDP multicast have been disabled. "
"Remove face_system.udp section to disable UDP channels or enable at least one of them."));
}
@@ -298,9 +298,8 @@
// check if the endpoint is already used by a multicast face
if (m_mcastFaces.find(localEndpoint) != m_mcastFaces.end()) {
- BOOST_THROW_EXCEPTION(Error("Cannot create UDP channel on " +
- boost::lexical_cast<std::string>(localEndpoint) +
- ", endpoint already allocated for a UDP multicast face"));
+ NDN_THROW(Error("Cannot create UDP channel on " + boost::lexical_cast<std::string>(localEndpoint) +
+ ", endpoint already allocated to a UDP multicast face"));
}
auto channel = std::make_shared<UdpChannel>(localEndpoint, idleTimeout, m_wantCongestionMarking);
@@ -338,16 +337,14 @@
if (it->second->getRemoteUri() == FaceUri(mcastEp))
return it->second;
else
- BOOST_THROW_EXCEPTION(Error("Cannot create UDP multicast face on " +
- boost::lexical_cast<std::string>(localEp) +
- ", endpoint already allocated for a different UDP multicast face"));
+ NDN_THROW(Error("Cannot create UDP multicast face on " + boost::lexical_cast<std::string>(localEp) +
+ ", endpoint already allocated to a different UDP multicast face"));
}
// check if the local endpoint is already used by a unicast channel
if (m_channels.find(localEp) != m_channels.end()) {
- BOOST_THROW_EXCEPTION(Error("Cannot create UDP multicast face on " +
- boost::lexical_cast<std::string>(localEp) +
- ", endpoint already allocated for a UDP channel"));
+ NDN_THROW(Error("Cannot create UDP multicast face on " + boost::lexical_cast<std::string>(localEp) +
+ ", endpoint already allocated to a UDP channel"));
}
ip::udp::socket rxSock(getGlobalIoService());
diff --git a/daemon/face/unix-stream-channel.cpp b/daemon/face/unix-stream-channel.cpp
index 8c58c55..172f797 100644
--- a/daemon/face/unix-stream-channel.cpp
+++ b/daemon/face/unix-stream-channel.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -82,8 +82,7 @@
NFD_LOG_CHAN_TRACE("connect() on existing socket file returned: " << error.message());
if (!error) {
// someone answered, leave the socket alone
- BOOST_THROW_EXCEPTION(Error("Socket file at " + m_endpoint.path()
- + " belongs to another NFD process"));
+ NDN_THROW(Error("Socket file at " + m_endpoint.path() + " belongs to another NFD process"));
}
else if (error == boost::asio::error::connection_refused ||
error == boost::asio::error::timed_out) {
@@ -94,7 +93,7 @@
}
}
else if (type != fs::file_not_found) {
- BOOST_THROW_EXCEPTION(Error(m_endpoint.path() + " already exists and is not a socket file"));
+ NDN_THROW(Error(m_endpoint.path() + " already exists and is not a socket file"));
}
m_acceptor.open();
@@ -102,7 +101,7 @@
m_acceptor.listen(backlog);
if (::chmod(m_endpoint.path().data(), 0666) < 0) {
- BOOST_THROW_EXCEPTION(Error("chmod(" + m_endpoint.path() + ") failed: " + std::strerror(errno)));
+ NDN_THROW_ERRNO(Error("Failed to chmod " + m_endpoint.path()));
}
accept(onFaceCreated, onAcceptFailed);
diff --git a/daemon/face/unix-stream-factory.cpp b/daemon/face/unix-stream-factory.cpp
index 211203a..faa406c 100644
--- a/daemon/face/unix-stream-factory.cpp
+++ b/daemon/face/unix-stream-factory.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -68,7 +68,7 @@
path = value.get_value<std::string>();
}
else {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("Unrecognized option face_system.unix." + key));
+ NDN_THROW(ConfigFile::Error("Unrecognized option face_system.unix." + key));
}
}
diff --git a/daemon/face/websocket-factory.cpp b/daemon/face/websocket-factory.cpp
index e3d8d57..49e5740 100644
--- a/daemon/face/websocket-factory.cpp
+++ b/daemon/face/websocket-factory.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -75,13 +75,13 @@
enableV6 = ConfigFile::parseYesNo(pair, "face_system.websocket");
}
else {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("Unrecognized option face_system.websocket." + key));
+ NDN_THROW(ConfigFile::Error("Unrecognized option face_system.websocket." + key));
}
}
}
if (!enableV4 && !enableV6) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error(
+ NDN_THROW(ConfigFile::Error(
"IPv4 and IPv6 WebSocket channels have been disabled. Remove face_system.websocket section "
"to disable WebSocket channels or enable at least one channel type."));
}
diff --git a/daemon/fw/access-strategy.cpp b/daemon/fw/access-strategy.cpp
index 31e2b91..13560a9 100644
--- a/daemon/fw/access-strategy.cpp
+++ b/daemon/fw/access-strategy.cpp
@@ -39,10 +39,10 @@
{
ParsedInstanceName parsed = parseInstanceName(name);
if (!parsed.parameters.empty()) {
- BOOST_THROW_EXCEPTION(std::invalid_argument("AccessStrategy does not accept parameters"));
+ NDN_THROW(std::invalid_argument("AccessStrategy does not accept parameters"));
}
if (parsed.version && *parsed.version != getStrategyName()[-1].toVersion()) {
- BOOST_THROW_EXCEPTION(std::invalid_argument(
+ NDN_THROW(std::invalid_argument(
"AccessStrategy does not support version " + to_string(*parsed.version)));
}
this->setInstanceName(makeInstanceName(name, getStrategyName()));
diff --git a/daemon/fw/asf-measurements.cpp b/daemon/fw/asf-measurements.cpp
index f743e06..6302020 100644
--- a/daemon/fw/asf-measurements.cpp
+++ b/daemon/fw/asf-measurements.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -85,7 +85,7 @@
m_lastInterestName = interestName;
}
else {
- BOOST_THROW_EXCEPTION(FaceInfo::Error("Tried to schedule a timeout for a face that already has a timeout scheduled."));
+ NDN_THROW(FaceInfo::Error("Tried to schedule a timeout for a face that already has a timeout scheduled"));
}
}
diff --git a/daemon/fw/asf-probing-module.cpp b/daemon/fw/asf-probing-module.cpp
index 8a81a77..dd2b537 100644
--- a/daemon/fw/asf-probing-module.cpp
+++ b/daemon/fw/asf-probing-module.cpp
@@ -197,9 +197,8 @@
m_probingInterval = time::milliseconds(probingInterval);
}
else {
- BOOST_THROW_EXCEPTION(std::invalid_argument("Probing interval should be >= "
- + to_string(MIN_PROBING_INTERVAL.count())
- + " milliseconds"));
+ NDN_THROW(std::invalid_argument("Probing interval should be >= " +
+ to_string(MIN_PROBING_INTERVAL.count()) + " milliseconds"));
}
}
diff --git a/daemon/fw/asf-strategy.cpp b/daemon/fw/asf-strategy.cpp
index d47649d..67d6944 100644
--- a/daemon/fw/asf-strategy.cpp
+++ b/daemon/fw/asf-strategy.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -52,7 +52,7 @@
}
if (parsed.version && *parsed.version != getStrategyName()[-1].toVersion()) {
- BOOST_THROW_EXCEPTION(std::invalid_argument(
+ NDN_THROW(std::invalid_argument(
"AsfStrategy does not support version " + to_string(*parsed.version)));
}
this->setInstanceName(makeInstanceName(name, getStrategyName()));
@@ -75,7 +75,7 @@
std::string parsedStr(reinterpret_cast<const char*>(component.value()), component.value_size());
auto n = parsedStr.find("~");
if (n == std::string::npos) {
- BOOST_THROW_EXCEPTION(std::invalid_argument("Format is <parameter>~<value>"));
+ NDN_THROW(std::invalid_argument("Format is <parameter>~<value>"));
}
auto f = parsedStr.substr(0, n);
@@ -87,7 +87,7 @@
m_maxSilentTimeouts = getParamValue(f, s);
}
else {
- BOOST_THROW_EXCEPTION(std::invalid_argument("Parameter should be probing-interval or n-silent-timeouts"));
+ NDN_THROW(std::invalid_argument("Parameter should be probing-interval or n-silent-timeouts"));
}
}
}
@@ -97,12 +97,12 @@
{
try {
if (!value.empty() && value[0] == '-')
- BOOST_THROW_EXCEPTION(boost::bad_lexical_cast());
+ NDN_THROW(boost::bad_lexical_cast());
return boost::lexical_cast<uint64_t>(value);
}
catch (const boost::bad_lexical_cast&) {
- BOOST_THROW_EXCEPTION(std::invalid_argument("Value of " + param + " must be a non-negative integer"));
+ NDN_THROW(std::invalid_argument("Value of " + param + " must be a non-negative integer"));
}
}
diff --git a/daemon/fw/best-route-strategy.cpp b/daemon/fw/best-route-strategy.cpp
index e4462e4..dbf410b 100644
--- a/daemon/fw/best-route-strategy.cpp
+++ b/daemon/fw/best-route-strategy.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -63,10 +63,10 @@
{
ParsedInstanceName parsed = parseInstanceName(name);
if (!parsed.parameters.empty()) {
- BOOST_THROW_EXCEPTION(std::invalid_argument("BestRouteStrategy does not accept parameters"));
+ NDN_THROW(std::invalid_argument("BestRouteStrategy does not accept parameters"));
}
if (parsed.version && *parsed.version != getStrategyName()[-1].toVersion()) {
- BOOST_THROW_EXCEPTION(std::invalid_argument(
+ NDN_THROW(std::invalid_argument(
"BestRouteStrategy does not support version " + to_string(*parsed.version)));
}
this->setInstanceName(makeInstanceName(name, getStrategyName()));
diff --git a/daemon/fw/best-route-strategy2.cpp b/daemon/fw/best-route-strategy2.cpp
index 0ab6b25..03f27dc 100644
--- a/daemon/fw/best-route-strategy2.cpp
+++ b/daemon/fw/best-route-strategy2.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -45,10 +45,10 @@
{
ParsedInstanceName parsed = parseInstanceName(name);
if (!parsed.parameters.empty()) {
- BOOST_THROW_EXCEPTION(std::invalid_argument("BestRouteStrategy2 does not accept parameters"));
+ NDN_THROW(std::invalid_argument("BestRouteStrategy2 does not accept parameters"));
}
if (parsed.version && *parsed.version != getStrategyName()[-1].toVersion()) {
- BOOST_THROW_EXCEPTION(std::invalid_argument(
+ NDN_THROW(std::invalid_argument(
"BestRouteStrategy2 does not support version " + to_string(*parsed.version)));
}
this->setInstanceName(makeInstanceName(name, getStrategyName()));
diff --git a/daemon/fw/multicast-strategy.cpp b/daemon/fw/multicast-strategy.cpp
index 6a05356..71fa7c1 100644
--- a/daemon/fw/multicast-strategy.cpp
+++ b/daemon/fw/multicast-strategy.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -46,10 +46,10 @@
{
ParsedInstanceName parsed = parseInstanceName(name);
if (!parsed.parameters.empty()) {
- BOOST_THROW_EXCEPTION(std::invalid_argument("MulticastStrategy does not accept parameters"));
+ NDN_THROW(std::invalid_argument("MulticastStrategy does not accept parameters"));
}
if (parsed.version && *parsed.version != getStrategyName()[-1].toVersion()) {
- BOOST_THROW_EXCEPTION(std::invalid_argument(
+ NDN_THROW(std::invalid_argument(
"MulticastStrategy does not support version " + to_string(*parsed.version)));
}
this->setInstanceName(makeInstanceName(name, getStrategyName()));
diff --git a/daemon/fw/ncc-strategy.cpp b/daemon/fw/ncc-strategy.cpp
index df9a41b..9a16897 100644
--- a/daemon/fw/ncc-strategy.cpp
+++ b/daemon/fw/ncc-strategy.cpp
@@ -42,10 +42,10 @@
{
ParsedInstanceName parsed = parseInstanceName(name);
if (!parsed.parameters.empty()) {
- BOOST_THROW_EXCEPTION(std::invalid_argument("NccStrategy does not accept parameters"));
+ NDN_THROW(std::invalid_argument("NccStrategy does not accept parameters"));
}
if (parsed.version && *parsed.version != getStrategyName()[-1].toVersion()) {
- BOOST_THROW_EXCEPTION(std::invalid_argument(
+ NDN_THROW(std::invalid_argument(
"NccStrategy does not support version " + to_string(*parsed.version)));
}
this->setInstanceName(makeInstanceName(name, getStrategyName()));
diff --git a/daemon/fw/self-learning-strategy.cpp b/daemon/fw/self-learning-strategy.cpp
index 5a43a26..174dca4 100644
--- a/daemon/fw/self-learning-strategy.cpp
+++ b/daemon/fw/self-learning-strategy.cpp
@@ -49,10 +49,10 @@
{
ParsedInstanceName parsed = parseInstanceName(name);
if (!parsed.parameters.empty()) {
- BOOST_THROW_EXCEPTION(std::invalid_argument("SelfLearningStrategy does not accept parameters"));
+ NDN_THROW(std::invalid_argument("SelfLearningStrategy does not accept parameters"));
}
if (parsed.version && *parsed.version != getStrategyName()[-1].toVersion()) {
- BOOST_THROW_EXCEPTION(std::invalid_argument(
+ NDN_THROW(std::invalid_argument(
"SelfLearningStrategy does not support version " + to_string(*parsed.version)));
}
this->setInstanceName(makeInstanceName(name, getStrategyName()));
diff --git a/daemon/mgmt/command-authenticator.cpp b/daemon/mgmt/command-authenticator.cpp
index 0b6346b..913c74f 100644
--- a/daemon/mgmt/command-authenticator.cpp
+++ b/daemon/mgmt/command-authenticator.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -124,14 +124,13 @@
}
if (section.empty()) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("'authorize' is missing under 'authorizations'"));
+ NDN_THROW(ConfigFile::Error("'authorize' is missing under 'authorizations'"));
}
int authSectionIndex = 0;
for (const auto& kv : section) {
if (kv.first != "authorize") {
- BOOST_THROW_EXCEPTION(ConfigFile::Error(
- "'" + kv.first + "' section is not permitted under 'authorizations'"));
+ NDN_THROW(ConfigFile::Error("'" + kv.first + "' section is not permitted under 'authorizations'"));
}
const ConfigSection& authSection = kv.second;
@@ -140,8 +139,8 @@
certfile = authSection.get<std::string>("certfile");
}
catch (const boost::property_tree::ptree_error&) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error(
- "'certfile' is missing under authorize[" + to_string(authSectionIndex) + "]"));
+ NDN_THROW(ConfigFile::Error("'certfile' is missing under authorize[" +
+ to_string(authSectionIndex) + "]"));
}
bool isAny = false;
@@ -156,9 +155,8 @@
path certfilePath = absolute(certfile, path(filename).parent_path());
cert = ndn::io::load<sec2::Certificate>(certfilePath.string());
if (cert == nullptr) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error(
- "cannot load certfile " + certfilePath.string() +
- " for authorize[" + to_string(authSectionIndex) + "]"));
+ NDN_THROW(ConfigFile::Error("cannot load certfile " + certfilePath.string() +
+ " for authorize[" + to_string(authSectionIndex) + "]"));
}
}
@@ -167,8 +165,8 @@
privSection = &authSection.get_child("privileges");
}
catch (const boost::property_tree::ptree_error&) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error(
- "'privileges' is missing under authorize[" + to_string(authSectionIndex) + "]"));
+ NDN_THROW(ConfigFile::Error("'privileges' is missing under authorize[" +
+ to_string(authSectionIndex) + "]"));
}
if (privSection->empty()) {
@@ -178,8 +176,8 @@
const std::string& module = kv.first;
auto found = m_validators.find(module);
if (found == m_validators.end()) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error(
- "unknown module '" + module + "' under authorize[" + to_string(authSectionIndex) + "]"));
+ NDN_THROW(ConfigFile::Error("unknown module '" + module +
+ "' under authorize[" + to_string(authSectionIndex) + "]"));
}
if (isDryRun) {
@@ -195,8 +193,7 @@
const Name& keyName = cert->getKeyName();
sec2::Certificate certCopy = *cert;
found->second->loadAnchor(certfile, std::move(certCopy));
- NFD_LOG_INFO("authorize module=" << module << " signer=" << keyName <<
- " certfile=" << certfile);
+ NFD_LOG_INFO("authorize module=" << module << " signer=" << keyName << " certfile=" << certfile);
}
}
diff --git a/daemon/mgmt/general-config-section.cpp b/daemon/mgmt/general-config-section.cpp
index 6ed3af1..732074b 100644
--- a/daemon/mgmt/general-config-section.cpp
+++ b/daemon/mgmt/general-config-section.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -45,25 +45,23 @@
if (i.first == "user") {
try {
user = i.second.get_value<std::string>("user");
-
if (user.empty()) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("Invalid value for \"user\" in \"general\" section"));
+ NDN_THROW(ConfigFile::Error("Invalid value for 'user' in section 'general'"));
}
}
catch (const boost::property_tree::ptree_error&) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("Invalid value for \"user\" in \"general\" section"));
+ NDN_THROW(ConfigFile::Error("Invalid value for 'user' in section 'general'"));
}
}
else if (i.first == "group") {
try {
group = i.second.get_value<std::string>("group");
-
if (group.empty()) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("Invalid value for \"group\" in \"general\" section"));
+ NDN_THROW(ConfigFile::Error("Invalid value for 'group' in section 'general'"));
}
}
catch (const boost::property_tree::ptree_error&) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("Invalid value for \"group\" in \"general\" section"));
+ NDN_THROW(ConfigFile::Error("Invalid value for 'group' in section 'general'"));
}
}
}
diff --git a/daemon/mgmt/tables-config-section.cpp b/daemon/mgmt/tables-config-section.cpp
index 678b6e5..e5383a4 100644
--- a/daemon/mgmt/tables-config-section.cpp
+++ b/daemon/mgmt/tables-config-section.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -72,8 +72,7 @@
std::string policyName = csPolicyNode->get_value<std::string>();
csPolicy = cs::Policy::create(policyName);
if (csPolicy == nullptr) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error(
- "Unknown cs_policy \"" + policyName + "\" in \"tables\" section"));
+ NDN_THROW(ConfigFile::Error("Unknown cs_policy '" + policyName + "' in section 'tables'"));
}
}
@@ -83,8 +82,7 @@
std::string policyName = unsolicitedDataPolicyNode->get_value<std::string>();
unsolicitedDataPolicy = fw::UnsolicitedDataPolicy::create(policyName);
if (unsolicitedDataPolicy == nullptr) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error(
- "Unknown cs_unsolicited_policy \"" + policyName + "\" in \"tables\" section"));
+ NDN_THROW(ConfigFile::Error("Unknown cs_unsolicited_policy '" + policyName + "' in section 'tables'"));
}
}
else {
@@ -127,15 +125,14 @@
Name strategy(prefixAndStrategy.second.get_value<std::string>());
if (!Strategy::canCreate(strategy)) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error(
- "Unknown strategy \"" + prefixAndStrategy.second.get_value<std::string>() +
- "\" for prefix \"" + prefix.toUri() + "\" in \"strategy_choice\" section"));
+ NDN_THROW(ConfigFile::Error(
+ "Unknown strategy '" + prefixAndStrategy.second.get_value<std::string>() +
+ "' for prefix '" + prefix.toUri() + "' in section 'strategy_choice'"));
}
if (!choices.emplace(prefix, strategy).second) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error(
- "Duplicate strategy choice for prefix \"" + prefix.toUri() +
- "\" in \"strategy_choice\" section"));
+ NDN_THROW(ConfigFile::Error(
+ "Duplicate strategy choice for prefix '" + prefix.toUri() + "' in section 'strategy_choice'"));
}
}
@@ -146,9 +143,9 @@
StrategyChoice& sc = m_forwarder.getStrategyChoice();
for (const auto& prefixAndStrategy : choices) {
if (!sc.insert(prefixAndStrategy.first, prefixAndStrategy.second)) {
- BOOST_THROW_EXCEPTION(ConfigFile::Error(
- "Failed to set strategy \"" + prefixAndStrategy.second.toUri() + "\" for "
- "prefix \"" + prefixAndStrategy.first.toUri() + "\" in \"strategy_choicev\""));
+ NDN_THROW(ConfigFile::Error(
+ "Failed to set strategy '" + prefixAndStrategy.second.toUri() + "' for prefix '" +
+ prefixAndStrategy.first.toUri() + "' in section 'strategy_choice'"));
}
}
///\todo redesign so that strategy parameter errors can be catched during dry-run
@@ -161,11 +158,10 @@
return;
}
- NetworkRegionTable& nrt = m_forwarder.getNetworkRegionTable();
+ auto& nrt = m_forwarder.getNetworkRegionTable();
nrt.clear();
for (const auto& pair : section) {
- Name region(pair.first);
- nrt.insert(region);
+ nrt.insert(Name(pair.first));
}
}
diff --git a/daemon/table/dead-nonce-list.cpp b/daemon/table/dead-nonce-list.cpp
index 144e68e..a5bd9f8 100644
--- a/daemon/table/dead-nonce-list.cpp
+++ b/daemon/table/dead-nonce-list.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -51,7 +51,7 @@
, m_adjustCapacityInterval(m_lifetime)
{
if (m_lifetime < MIN_LIFETIME) {
- BOOST_THROW_EXCEPTION(std::invalid_argument("lifetime is less than MIN_LIFETIME"));
+ NDN_THROW(std::invalid_argument("lifetime is less than MIN_LIFETIME"));
}
for (size_t i = 0; i < EXPECTED_MARK_COUNT; ++i) {
diff --git a/rib/fib-updater.cpp b/rib/fib-updater.cpp
index 1d6328c..574b5f9 100644
--- a/rib/fib-updater.cpp
+++ b/rib/fib-updater.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -305,8 +305,7 @@
}
}
else {
- BOOST_THROW_EXCEPTION(Error("Non-recoverable error: " + response.getText() +
- " code: " + to_string(code)));
+ NDN_THROW(Error("Non-recoverable error: " + response.getText() + " code: " + to_string(code)));
}
}
diff --git a/rib/rib-manager.cpp b/rib/rib-manager.cpp
index d09420e..4477ebc 100644
--- a/rib/rib-manager.cpp
+++ b/rib/rib-manager.cpp
@@ -108,12 +108,12 @@
{
m_nfdController.start<ndn::nfd::FaceUpdateCommand>(
ControlParameters().setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, true),
- [] (const ControlParameters& res) {
+ [] (const ControlParameters&) {
NFD_LOG_DEBUG("Local fields enabled");
},
[] (const ControlResponse& res) {
- BOOST_THROW_EXCEPTION(Error("Couldn't enable local fields (" + to_string(res.getCode()) +
- " " + res.getText() + ")"));
+ NDN_THROW(Error("Couldn't enable local fields (" + to_string(res.getCode()) +
+ " " + res.getText() + ")"));
});
}
@@ -205,8 +205,8 @@
m_registeredFaces.insert(route.faceId);
},
[=] (const ControlResponse& res) {
- BOOST_THROW_EXCEPTION(Error("Cannot add FIB entry " + topPrefix.toUri() + " (" +
- to_string(res.getCode()) + " " + res.getText() + ")"));
+ NDN_THROW(Error("Cannot add FIB entry " + topPrefix.toUri() + " (" +
+ to_string(res.getCode()) + " " + res.getText() + ")"));
});
// add top prefix to the dispatcher without prefix registration
diff --git a/rib/service.cpp b/rib/service.cpp
index a91a93e..35c092d 100644
--- a/rib/service.cpp
+++ b/rib/service.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -82,7 +82,7 @@
return make_shared<ndn::TcpTransport>("localhost", port);
}
else {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("No transport is available to communicate with NFD"));
+ NDN_THROW(ConfigFile::Error("No transport is available to communicate with NFD"));
}
}
@@ -114,10 +114,10 @@
, m_ribManager(m_rib, m_face, m_keyChain, m_nfdController, m_dispatcher, m_scheduler)
{
if (s_instance != nullptr) {
- BOOST_THROW_EXCEPTION(std::logic_error("RIB service cannot be instantiated more than once"));
+ NDN_THROW(std::logic_error("RIB service cannot be instantiated more than once"));
}
if (&getGlobalIoService() != &getRibIoService()) {
- BOOST_THROW_EXCEPTION(std::logic_error("RIB service must run on RIB thread"));
+ NDN_THROW(std::logic_error("RIB service must run on RIB thread"));
}
s_instance = this;
@@ -139,10 +139,10 @@
Service::get()
{
if (s_instance == nullptr) {
- BOOST_THROW_EXCEPTION(std::logic_error("RIB service is not instantiated"));
+ NDN_THROW(std::logic_error("RIB service is not instantiated"));
}
if (&getGlobalIoService() != &getRibIoService()) {
- BOOST_THROW_EXCEPTION(std::logic_error("Must get RIB service on RIB thread"));
+ NDN_THROW(std::logic_error("Must get RIB service on RIB thread"));
}
return *s_instance;
}
@@ -175,7 +175,7 @@
ConfigFile::parseYesNo(item, CFG_SECTION + "." + CFG_READVERTISE_NLSR);
}
else {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("Unrecognized option " + CFG_SECTION + "." + key));
+ NDN_THROW(ConfigFile::Error("Unrecognized option " + CFG_SECTION + "." + key));
}
}
}
@@ -228,7 +228,7 @@
wantReadvertiseNlsr = ConfigFile::parseYesNo(item, CFG_SECTION + "." + CFG_READVERTISE_NLSR);
}
else {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("Unrecognized option " + CFG_SECTION + "." + key));
+ NDN_THROW(ConfigFile::Error("Unrecognized option " + CFG_SECTION + "." + key));
}
}
diff --git a/tests/daemon/face/channel-fixture.hpp b/tests/daemon/face/channel-fixture.hpp
index f764125..7efedfd 100644
--- a/tests/daemon/face/channel-fixture.hpp
+++ b/tests/daemon/face/channel-fixture.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -63,16 +63,15 @@
virtual unique_ptr<ChannelT>
makeChannel()
{
- BOOST_THROW_EXCEPTION(std::logic_error("unimplemented"));
+ BOOST_FAIL("Unimplemented");
+ return nullptr;
}
- /**
- * if port == 0, use the port number returned by getNextPort()
- */
virtual unique_ptr<ChannelT>
- makeChannel(const boost::asio::ip::address& addr, uint16_t port = 0)
+ makeChannel(const boost::asio::ip::address&, uint16_t port = 0)
{
- BOOST_THROW_EXCEPTION(std::logic_error("unimplemented"));
+ BOOST_FAIL("Unimplemented");
+ return nullptr;
}
void
@@ -93,7 +92,7 @@
virtual void
connect(ChannelT&)
{
- BOOST_THROW_EXCEPTION(std::logic_error("unimplemented"));
+ BOOST_FAIL("Unimplemented");
}
protected:
diff --git a/tests/daemon/face/udp-factory.t.cpp b/tests/daemon/face/udp-factory.t.cpp
index 088b300..0c10276 100644
--- a/tests/daemon/face/udp-factory.t.cpp
+++ b/tests/daemon/face/udp-factory.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -869,14 +869,14 @@
SKIP_IF_NOT_SUPERUSER();
#endif // __linux__
- // createChannel with a local endpoint that has already been allocated for a UDP multicast face
+ // createChannel with a local endpoint that has already been allocated to a UDP multicast face
if (!netifsV4.empty()) {
auto mcastFace = createMulticastFace("127.0.0.1", "224.0.0.254", 20072);
BOOST_CHECK_EXCEPTION(createChannel("127.0.0.1", 20072), UdpFactory::Error,
[] (const UdpFactory::Error& e) {
return strcmp(e.what(),
"Cannot create UDP channel on 127.0.0.1:20072, "
- "endpoint already allocated for a UDP multicast face") == 0;
+ "endpoint already allocated to a UDP multicast face") == 0;
});
}
if (!netifsV6.empty()) {
@@ -885,7 +885,7 @@
[] (const UdpFactory::Error& e) {
return strcmp(e.what(),
"Cannot create UDP channel on [::1]:20072, "
- "endpoint already allocated for a UDP multicast face") == 0;
+ "endpoint already allocated to a UDP multicast face") == 0;
});
}
}
@@ -917,7 +917,7 @@
[] (const UdpFactory::Error& e) {
return strcmp(e.what(),
"Cannot create UDP multicast face on 127.0.0.1:20071, "
- "endpoint already allocated for a UDP channel") == 0;
+ "endpoint already allocated to a UDP channel") == 0;
});
// create with a local endpoint already used by a multicast face on a different multicast group
@@ -925,7 +925,7 @@
[] (const UdpFactory::Error& e) {
return strcmp(e.what(),
"Cannot create UDP multicast face on 127.0.0.1:20070, "
- "endpoint already allocated for a different UDP multicast face") == 0;
+ "endpoint already allocated to a different UDP multicast face") == 0;
});
}
@@ -956,7 +956,7 @@
[] (const UdpFactory::Error& e) {
return strcmp(e.what(),
"Cannot create UDP multicast face on [::1]:20071, "
- "endpoint already allocated for a UDP channel") == 0;
+ "endpoint already allocated to a UDP channel") == 0;
});
// create with a local endpoint already used by a multicast face on a different multicast group
@@ -964,7 +964,7 @@
[] (const UdpFactory::Error& e) {
return strcmp(e.what(),
"Cannot create UDP multicast face on [::1]:20070, "
- "endpoint already allocated for a different UDP multicast face") == 0;
+ "endpoint already allocated to a different UDP multicast face") == 0;
});
}
diff --git a/tests/daemon/fw/choose-strategy.hpp b/tests/daemon/fw/choose-strategy.hpp
index 4045540..0da7b84 100644
--- a/tests/daemon/fw/choose-strategy.hpp
+++ b/tests/daemon/fw/choose-strategy.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -28,6 +28,7 @@
#include "fw/forwarder.hpp"
#include "table/strategy-choice.hpp"
+
#include <boost/lexical_cast.hpp>
namespace nfd {
@@ -54,7 +55,7 @@
StrategyChoice& sc = forwarder.getStrategyChoice();
auto insertRes = sc.insert(prefix, instanceName);
if (!insertRes) {
- BOOST_THROW_EXCEPTION(std::invalid_argument(boost::lexical_cast<std::string>(insertRes)));
+ NDN_THROW(std::invalid_argument(boost::lexical_cast<std::string>(insertRes)));
}
return dynamic_cast<S&>(sc.findEffectiveStrategy(prefix));
}
diff --git a/tests/daemon/mgmt/general-config-section.t.cpp b/tests/daemon/mgmt/general-config-section.t.cpp
index a12b09b..98b9458 100644
--- a/tests/daemon/mgmt/general-config-section.t.cpp
+++ b/tests/daemon/mgmt/general-config-section.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -138,7 +138,7 @@
ConfigFile::Error,
[] (const ConfigFile::Error& e) {
return std::strcmp(e.what(),
- "Invalid value for \"user\" in \"general\" section") == 0;
+ "Invalid value for 'user' in section 'general'") == 0;
});
}
@@ -155,7 +155,7 @@
ConfigFile::Error,
[] (const ConfigFile::Error& e) {
return std::strcmp(e.what(),
- "Invalid value for \"group\" in \"general\" section") == 0;
+ "Invalid value for 'group' in section 'general'") == 0;
});
}
diff --git a/tests/identity-management-fixture.cpp b/tests/identity-management-fixture.cpp
index ab361fd..e9b2762 100644
--- a/tests/identity-management-fixture.cpp
+++ b/tests/identity-management-fixture.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -94,7 +94,7 @@
}
catch (const ndn::security::Pib::Error&) {
if (!wantAdd) {
- BOOST_THROW_EXCEPTION(std::runtime_error("identity does not exist"));
+ NDN_THROW_NESTED(std::runtime_error("Identity does not exist"));
}
cert = m_keyChain.createIdentity(identity).getDefaultKey().getDefaultCertificate();
}
diff --git a/tests/limited-io.cpp b/tests/limited-io.cpp
index 9f8f4dc..f31ec9c 100644
--- a/tests/limited-io.cpp
+++ b/tests/limited-io.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -98,7 +98,7 @@
m_reason = EXCEED_OPS;
getGlobalIoService().stop();
if (m_uttf != nullptr) {
- BOOST_THROW_EXCEPTION(StopException());
+ NDN_THROW(StopException());
}
}
}
@@ -109,7 +109,7 @@
m_reason = EXCEED_TIME;
getGlobalIoService().stop();
if (m_uttf != nullptr) {
- BOOST_THROW_EXCEPTION(StopException());
+ NDN_THROW(StopException());
}
}
diff --git a/tests/other/face-benchmark.cpp b/tests/other/face-benchmark.cpp
index 007a87b..5745c03 100644
--- a/tests/other/face-benchmark.cpp
+++ b/tests/other/face-benchmark.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -94,7 +94,7 @@
}
if (m_faceUris.empty()) {
- BOOST_THROW_EXCEPTION(std::runtime_error("No supported FaceUri pairs found in config file"));
+ NDN_THROW(std::runtime_error("No supported FaceUri pairs found in config file"));
}
}
@@ -159,7 +159,7 @@
static void
onFaceCreationFailed(uint32_t status, const std::string& reason)
{
- BOOST_THROW_EXCEPTION(std::runtime_error("Failed to create face: " + to_string(status) + ": " + reason));
+ NDN_THROW(std::runtime_error("Failed to create face: [" + to_string(status) + "] " + reason));
}
private:
diff --git a/tests/other/fw/congestion-mark-strategy.cpp b/tests/other/fw/congestion-mark-strategy.cpp
index 717853f..744608f 100644
--- a/tests/other/fw/congestion-mark-strategy.cpp
+++ b/tests/other/fw/congestion-mark-strategy.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -41,7 +41,7 @@
switch (parsed.parameters.size()) {
case 2:
if (parsed.parameters.at(1).toUri() != "true" && parsed.parameters.at(1).toUri() != "false") {
- BOOST_THROW_EXCEPTION(std::invalid_argument(
+ NDN_THROW(std::invalid_argument(
"Second parameter to CongestionMarkStrategy must be either 'true' or 'false'"));
}
m_shouldPreserveMark = parsed.parameters.at(1).toUri() == "true";
@@ -50,22 +50,22 @@
try {
auto s = parsed.parameters.at(0).toUri();
if (!s.empty() && s[0] == '-')
- BOOST_THROW_EXCEPTION(boost::bad_lexical_cast());
+ NDN_THROW(boost::bad_lexical_cast());
m_congestionMark = boost::lexical_cast<uint64_t>(s);
}
catch (const boost::bad_lexical_cast&) {
- BOOST_THROW_EXCEPTION(std::invalid_argument(
+ NDN_THROW(std::invalid_argument(
"First parameter to CongestionMarkStrategy must be a non-negative integer"));
}
NDN_CXX_FALLTHROUGH;
case 0:
break;
default:
- BOOST_THROW_EXCEPTION(std::invalid_argument("CongestionMarkStrategy does not accept more than 2 parameters"));
+ NDN_THROW(std::invalid_argument("CongestionMarkStrategy does not accept more than 2 parameters"));
}
if (parsed.version && *parsed.version != getStrategyName()[-1].toVersion()) {
- BOOST_THROW_EXCEPTION(std::invalid_argument(
+ NDN_THROW(std::invalid_argument(
"CongestionMarkStrategy does not support version " + to_string(*parsed.version)));
}
this->setInstanceName(makeInstanceName(name, getStrategyName()));
diff --git a/tools/ndn-autoconfig/dns-srv.cpp b/tools/ndn-autoconfig/dns-srv.cpp
index f099295..574ef17 100644
--- a/tools/ndn-autoconfig/dns-srv.cpp
+++ b/tools/ndn-autoconfig/dns-srv.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -78,7 +78,7 @@
uint16_t ancount = queryAnswer.header.ancount;
if (boost::endian::big_to_native(ancount) == 0) {
- BOOST_THROW_EXCEPTION(DnsSrvError("SRV record cannot be parsed"));
+ NDN_THROW(DnsSrvError("SRV record cannot be parsed"));
}
const uint8_t* blob = queryAnswer.buf + NS_HFIXEDSZ;
@@ -91,7 +91,7 @@
srvName, // expanded server name
NS_MAXDNAME);
if (serverNameSize <= 0) {
- BOOST_THROW_EXCEPTION(DnsSrvError("SRV record cannot be parsed (error decoding domain name)"));
+ NDN_THROW(DnsSrvError("SRV record cannot be parsed (error decoding domain name)"));
}
const srv_t* server = reinterpret_cast<const srv_t*>(&blob[sizeof(rechdr)]);
@@ -106,7 +106,7 @@
hostName, // expanded host name
NS_MAXDNAME);
if (hostNameSize <= 0) {
- BOOST_THROW_EXCEPTION(DnsSrvError("SRV record cannot be parsed (error decoding host name)"));
+ NDN_THROW(DnsSrvError("SRV record cannot be parsed (error decoding host name)"));
}
return "udp://"s + hostName + ":" + to_string(port);
@@ -131,7 +131,7 @@
queryAnswer.buf,
sizeof(queryAnswer));
if (answerSize == 0) {
- BOOST_THROW_EXCEPTION(DnsSrvError("No DNS SRV records found for " + srvDomain));
+ NDN_THROW(DnsSrvError("No DNS SRV records found for " + srvDomain));
}
return parseSrvRr(queryAnswer, answerSize);
}
@@ -159,7 +159,7 @@
sizeof(queryAnswer));
if (answerSize == 0) {
- BOOST_THROW_EXCEPTION(DnsSrvError("No DNS SRV records found for _ndn._udp"));
+ NDN_THROW(DnsSrvError("No DNS SRV records found for _ndn._udp"));
}
return parseSrvRr(queryAnswer, answerSize);
diff --git a/tools/ndn-autoconfig/ndn-fch-discovery.cpp b/tools/ndn-autoconfig/ndn-fch-discovery.cpp
index abb934f..879ea8e 100644
--- a/tools/ndn-autoconfig/ndn-fch-discovery.cpp
+++ b/tools/ndn-autoconfig/ndn-fch-discovery.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -154,15 +154,15 @@
Url url(m_url);
if (!url.isValid()) {
- BOOST_THROW_EXCEPTION(HttpException("Invalid NDN-FCH URL: " + m_url));
+ NDN_THROW(HttpException("Invalid NDN-FCH URL: " + m_url));
}
if (!boost::iequals(url.getScheme(), "http")) {
- BOOST_THROW_EXCEPTION(HttpException("Only http:// NDN-FCH URLs are supported"));
+ NDN_THROW(HttpException("Only http:// NDN-FCH URLs are supported"));
}
requestStream.connect(url.getHost(), url.getPort());
if (!requestStream) {
- BOOST_THROW_EXCEPTION(HttpException("HTTP connection error to " + m_url));
+ NDN_THROW(HttpException("HTTP connection error to " + m_url));
}
requestStream << "GET " << url.getPath() << " HTTP/1.0\r\n";
@@ -175,7 +175,7 @@
std::string statusLine;
std::getline(requestStream, statusLine);
if (!requestStream) {
- BOOST_THROW_EXCEPTION(HttpException("HTTP communication error"));
+ NDN_THROW(HttpException("HTTP communication error"));
}
std::stringstream responseStream(statusLine);
@@ -187,11 +187,11 @@
std::getline(responseStream, statusMessage);
if (!static_cast<bool>(requestStream) || httpVersion.substr(0, 5) != "HTTP/") {
- BOOST_THROW_EXCEPTION(HttpException("HTTP communication error"));
+ NDN_THROW(HttpException("HTTP communication error"));
}
if (statusCode != 200) {
boost::trim(statusMessage);
- BOOST_THROW_EXCEPTION(HttpException("HTTP request failed: " + to_string(statusCode) + " " + statusMessage));
+ NDN_THROW(HttpException("HTTP request failed: " + to_string(statusCode) + " " + statusMessage));
}
std::string header;
while (std::getline(requestStream, header) && header != "\r")
@@ -200,7 +200,7 @@
std::string hubHost;
requestStream >> hubHost;
if (hubHost.empty()) {
- BOOST_THROW_EXCEPTION(HttpException("NDN-FCH did not return hub host"));
+ NDN_THROW(HttpException("NDN-FCH did not return hub host"));
}
this->provideHubFaceUri("udp://" + hubHost);
diff --git a/tools/ndn-autoconfig/stage.cpp b/tools/ndn-autoconfig/stage.cpp
index 2e1e048..0569b24 100644
--- a/tools/ndn-autoconfig/stage.cpp
+++ b/tools/ndn-autoconfig/stage.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -33,7 +33,7 @@
Stage::start()
{
if (m_isInProgress) {
- BOOST_THROW_EXCEPTION(Error("Cannot start a stage when it's in progress"));
+ NDN_THROW(Error("Cannot start a stage when it's in progress"));
}
m_isInProgress = true;
diff --git a/tools/nfdc/command-definition.cpp b/tools/nfdc/command-definition.cpp
index 9dce67a..4d92ca7 100644
--- a/tools/nfdc/command-definition.cpp
+++ b/tools/nfdc/command-definition.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -146,7 +146,7 @@
NDN_LOG_TRACE(token << " is a no-param argument");
}
else if (i + 1 >= tokens.size()) {
- BOOST_THROW_EXCEPTION(Error(arg.name + ": " + arg.metavar + " is missing"));
+ NDN_THROW(Error(arg.name + ": " + arg.metavar + " is missing"));
}
else {
const std::string& valueToken = tokens[++i];
@@ -156,8 +156,8 @@
}
catch (const std::exception& e) {
NDN_LOG_TRACE(valueToken << " cannot be parsed as " << arg.valueType);
- BOOST_THROW_EXCEPTION(Error(arg.name + ": cannot parse '" + valueToken + "' as " +
- arg.metavar + " (" + e.what() + ")"));
+ NDN_THROW_NESTED(Error(arg.name + ": cannot parse '" + valueToken + "' as " +
+ arg.metavar + " (" + e.what() + ")"));
}
NDN_LOG_TRACE(valueToken << " is parsed as " << arg.valueType);
}
@@ -188,8 +188,8 @@
catch (const std::exception& e) {
if (arg.isRequired) { // the current token must be parsed as the value for arg
NDN_LOG_TRACE(token << " cannot be parsed as value for " << arg.name);
- BOOST_THROW_EXCEPTION(Error("cannot parse '" + token + "' as an argument name or as " +
- arg.metavar + " for " + arg.name + " (" + e.what() + ")"));
+ NDN_THROW_NESTED(Error("cannot parse '" + token + "' as an argument name or as " +
+ arg.metavar + " for " + arg.name + " (" + e.what() + ")"));
}
else {
// the current token may be a value for next positional argument
@@ -201,7 +201,7 @@
if (positionalArgIndex >= m_positionalArgs.size()) {
// for loop has reached the end without finding a match,
// which means token is not accepted as a value for positional argument
- BOOST_THROW_EXCEPTION(Error("cannot parse '" + token + "' as an argument name"));
+ NDN_THROW(Error("cannot parse '" + token + "' as an argument name"));
}
// token is accepted; don't parse as the same positional argument again
@@ -210,7 +210,7 @@
for (const std::string& argName : m_requiredArgs) {
if (ca.count(argName) == 0) {
- BOOST_THROW_EXCEPTION(Error(argName + ": required argument is missing"));
+ NDN_THROW(Error(argName + ": required argument is missing"));
}
}
@@ -226,7 +226,7 @@
if (s == "off" || s == "false" || s == "disabled" || s == "no" || s == "0") {
return false;
}
- BOOST_THROW_EXCEPTION(std::invalid_argument("unrecognized boolean value '" + s + "'"));
+ NDN_THROW(std::invalid_argument("unrecognized boolean value '" + s + "'"));
}
static FacePersistency
@@ -238,7 +238,7 @@
if (s == "permanent") {
return FacePersistency::FACE_PERSISTENCY_PERMANENT;
}
- BOOST_THROW_EXCEPTION(std::invalid_argument("unrecognized FacePersistency '" + s + "'"));
+ NDN_THROW(std::invalid_argument("unrecognized FacePersistency '" + s + "'"));
}
ndn::any
@@ -257,7 +257,7 @@
// boost::lexical_cast<uint64_t> will accept negative number
int64_t v = boost::lexical_cast<int64_t>(token);
if (v < 0) {
- BOOST_THROW_EXCEPTION(std::out_of_range("value '" + token + "' is negative"));
+ NDN_THROW(std::out_of_range("value '" + token + "' is negative"));
}
return static_cast<uint64_t>(v);
}
diff --git a/tools/nfdc/command-parser.cpp b/tools/nfdc/command-parser.cpp
index a201272..9153890 100644
--- a/tools/nfdc/command-parser.cpp
+++ b/tools/nfdc/command-parser.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -119,7 +119,7 @@
auto i = m_commands.find({noun, verb});
if (i == m_commands.end() || (i->second->modes & static_cast<AvailableIn>(mode)) == 0) {
- BOOST_THROW_EXCEPTION(NoSuchCommandError(noun, verb));
+ NDN_THROW(NoSuchCommandError(noun, verb));
}
const CommandDefinition& def = i->second->def;
diff --git a/tools/nfdc/status-report.cpp b/tools/nfdc/status-report.cpp
index 01ad5c6..aa3cdf1 100644
--- a/tools/nfdc/status-report.cpp
+++ b/tools/nfdc/status-report.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -39,7 +39,7 @@
if (s == "text") {
return ReportFormat::TEXT;
}
- BOOST_THROW_EXCEPTION(std::invalid_argument("unrecognized ReportFormat '" + s + "'"));
+ NDN_THROW(std::invalid_argument("unrecognized ReportFormat '" + s + "'"));
}
std::ostream&
@@ -85,7 +85,7 @@
StatusReport::formatXml(std::ostream& os) const
{
xml::printHeader(os);
- for (const unique_ptr<Module>& module : sections) {
+ for (const auto& module : sections) {
module->formatStatusXml(os);
}
xml::printFooter(os);
@@ -94,7 +94,7 @@
void
StatusReport::formatText(std::ostream& os) const
{
- for (const unique_ptr<Module>& module : sections) {
+ for (const auto& module : sections) {
module->formatStatusText(os);
}
}