diff --git a/core/common.hpp b/core/common.hpp index 2678a173..93c29332 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 #include #include +#include #include #include @@ -72,7 +73,6 @@ #include #include #include -#include namespace nfd { diff --git a/core/config-file.cpp b/core/config-file.cpp index 548d351e..accfe729 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 + #include #include @@ -42,8 +43,8 @@ ConfigFile::throwErrorOnUnknownSection(const std::string& filename, 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 @@ ConfigFile::parseYesNo(const ConfigSection& node, const std::string& key, 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 @@ ConfigFile::parse(const std::string& filename, bool isDryRun) { 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 @@ ConfigFile::parse(std::istream& input, bool isDryRun, const std::string& filenam 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 d51b1e9f..819b9b48 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 @@ public: 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 @@ public: // parse helpers if (value) { return *value; } - BOOST_THROW_EXCEPTION(Error("Invalid value \"" + node.get_value() + - "\" for option \"" + key + "\" in \"" + sectionName + "\" section")); + NDN_THROW(Error("Invalid value '" + node.get_value() + + "' for option '" + key + "' in section '" + sectionName + "'")); } template diff --git a/core/log-config-section.cpp b/core/log-config-section.cpp index 6f6f0ab1..9d8168c4 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 @@ parseLogLevel(const ConfigSection& item, const std::string& key) try { return ndn::util::parseLogLevel(item.get_value()); } - 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 d10a5e33..43a0d401 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 @@ NetworkPredicateBase::clear() } void -NetworkPredicateBase::parseList(std::set& set, const boost::property_tree::ptree& list, const std::string& section) +NetworkPredicateBase::parseList(std::set& set, + const boost::property_tree::ptree& list, + const std::string& section) { set.clear(); @@ -58,12 +60,14 @@ NetworkPredicateBase::parseList(std::set& set, const boost::propert } 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(); 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 @@ NetworkPredicateBase::parseList(std::set& set, const boost::propert } void -NetworkPredicateBase::parseList(std::set& set, std::initializer_list> list) +NetworkPredicateBase::parseList(std::set& set, + std::initializer_list> list) { set.clear(); @@ -82,11 +87,11 @@ NetworkPredicateBase::parseList(std::set& set, std::initializer_lis } 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 @@ NetworkInterfacePredicate::isRuleValid(const std::string& key, const std::string 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 @@ IpAddressPredicate::isRuleValid(const std::string& key, const std::string& value 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 bbf08e2d..0379b2f0 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 @@ public: /** \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 691b40b0..21949b34 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 @@ EthernetChannel::listen(const FaceCreatedCallback& onFaceCreated, 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 76033434..4d4d2950 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 @@ EthernetFactory::doProcessConfig(OptionalConfigSection configSection, const std::string& valueStr = value.get_value(); 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 @@ EthernetFactory::doProcessConfig(OptionalConfigSection configSection, 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 412bcba7..ee7193bc 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 @@ EthernetTransport::EthernetTransport(const ndn::net::NetworkInterface& localEndp 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 79880da0..21685f30 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 @@ FaceSystem::processConfig(const ConfigSection& configSection, bool isDryRun, con 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 @@ FaceSystem::processConfig(const ConfigSection& configSection, bool isDryRun, con // 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 @@ FaceSystem::processConfig(const ConfigSection& configSection, bool isDryRun, con 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 7b248fb8..d46356bf 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 @@ LpReliability::assignTxSequence(lp::Packet& frag) lp::Sequence txSeq = ++m_lastTxSeqNo; frag.set(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 91c25d4e..2afb793f 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 @@ MulticastEthernetTransport::joinMulticastGroup() 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 db121288..6e99a1ce 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 @@ bindToDevice(int fd, const std::string& ifname) #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 a47bd439..5ed975d2 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 @@ NetdevBound::processConfig(OptionalConfigSection configSection, 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 @@ NetdevBound::processConfig(OptionalConfigSection configSection, 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 @@ NetdevBound::parseRule(int index, const ConfigSection& confRule) const try { rule.remotes.emplace_back(value.get_value()); } - 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 17a6ce89..6297afdd 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 @@ public: { } - 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 072f75ed..4b474e65 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 @@ PcapHelper::PcapHelper(const std::string& interfaceName) 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 @@ PcapHelper::activate(int dlt) { 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 @@ PcapHelper::getFd() const { 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 @@ PcapHelper::getNDropped() const { 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 @@ PcapHelper::setPacketFilter(const char* filter) const { 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 diff --git a/daemon/face/protocol-factory.cpp b/daemon/face/protocol-factory.cpp index cdb6cb17..5acb18f8 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 @@ shared_ptr ProtocolFactory::doCreateNetdevBoundFace(const FaceUri&, const shared_ptr&) { - 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> diff --git a/daemon/face/tcp-factory.cpp b/daemon/face/tcp-factory.cpp index d77b639e..f45d786c 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 @@ TcpFactory::doProcessConfig(OptionalConfigSection configSection, 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 @@ TcpFactory::doProcessConfig(OptionalConfigSection configSection, } 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 c08990a2..e93480fc 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 @@ Transport::setState(TransportState newState) } 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 6c261fbd..67303898 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 @@ UdpFactory::doProcessConfig(OptionalConfigSection configSection, 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 @@ UdpFactory::doProcessConfig(OptionalConfigSection configSection, 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 @@ UdpFactory::doProcessConfig(OptionalConfigSection configSection, 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 @@ UdpFactory::createChannel(const udp::Endpoint& localEndpoint, // 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(localEndpoint) + - ", endpoint already allocated for a UDP multicast face")); + NDN_THROW(Error("Cannot create UDP channel on " + boost::lexical_cast(localEndpoint) + + ", endpoint already allocated to a UDP multicast face")); } auto channel = std::make_shared(localEndpoint, idleTimeout, m_wantCongestionMarking); @@ -338,16 +337,14 @@ UdpFactory::createMulticastFace(const shared_ptr& n if (it->second->getRemoteUri() == FaceUri(mcastEp)) return it->second; else - BOOST_THROW_EXCEPTION(Error("Cannot create UDP multicast face on " + - boost::lexical_cast(localEp) + - ", endpoint already allocated for a different UDP multicast face")); + NDN_THROW(Error("Cannot create UDP multicast face on " + boost::lexical_cast(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(localEp) + - ", endpoint already allocated for a UDP channel")); + NDN_THROW(Error("Cannot create UDP multicast face on " + boost::lexical_cast(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 8c58c550..172f797d 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 @@ UnixStreamChannel::listen(const FaceCreatedCallback& onFaceCreated, 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 @@ UnixStreamChannel::listen(const FaceCreatedCallback& onFaceCreated, } } 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 @@ UnixStreamChannel::listen(const FaceCreatedCallback& onFaceCreated, 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 211203ac..faa406c1 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 @@ UnixStreamFactory::doProcessConfig(OptionalConfigSection configSection, path = value.get_value(); } 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 e3d8d574..49e57402 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 @@ WebSocketFactory::doProcessConfig(OptionalConfigSection configSection, 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 31e2b917..13560a9b 100644 --- a/daemon/fw/access-strategy.cpp +++ b/daemon/fw/access-strategy.cpp @@ -39,10 +39,10 @@ AccessStrategy::AccessStrategy(Forwarder& forwarder, const Name& name) { 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 f743e06b..63020201 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 @@ FaceInfo::setTimeoutEvent(const scheduler::EventId& id, const Name& interestName 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 8a81a776..dd2b5377 100644 --- a/daemon/fw/asf-probing-module.cpp +++ b/daemon/fw/asf-probing-module.cpp @@ -197,9 +197,8 @@ ProbingModule::setProbingInterval(size_t probingInterval) 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 d47649d1..67d6944e 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 @@ AsfStrategy::AsfStrategy(Forwarder& forwarder, const Name& name) } 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 @@ AsfStrategy::processParams(const PartialName& parsed) std::string parsedStr(reinterpret_cast(component.value()), component.value_size()); auto n = parsedStr.find("~"); if (n == std::string::npos) { - BOOST_THROW_EXCEPTION(std::invalid_argument("Format is ~")); + NDN_THROW(std::invalid_argument("Format is ~")); } auto f = parsedStr.substr(0, n); @@ -87,7 +87,7 @@ AsfStrategy::processParams(const PartialName& parsed) 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 @@ AsfStrategy::getParamValue(const std::string& param, const std::string& value) { try { if (!value.empty() && value[0] == '-') - BOOST_THROW_EXCEPTION(boost::bad_lexical_cast()); + NDN_THROW(boost::bad_lexical_cast()); return boost::lexical_cast(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 e4462e42..dbf410b4 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 @@ BestRouteStrategy::BestRouteStrategy(Forwarder& forwarder, const Name& name) { 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 0ab6b253..03f27dc0 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 @@ BestRouteStrategy2::BestRouteStrategy2(Forwarder& forwarder, const Name& name) { 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 6a05356a..71fa7c17 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 @@ MulticastStrategy::MulticastStrategy(Forwarder& forwarder, const Name& name) { 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 df9a41b5..9a168970 100644 --- a/daemon/fw/ncc-strategy.cpp +++ b/daemon/fw/ncc-strategy.cpp @@ -42,10 +42,10 @@ NccStrategy::NccStrategy(Forwarder& forwarder, const Name& name) { 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 5a43a264..174dca4d 100644 --- a/daemon/fw/self-learning-strategy.cpp +++ b/daemon/fw/self-learning-strategy.cpp @@ -49,10 +49,10 @@ SelfLearningStrategy::SelfLearningStrategy(Forwarder& forwarder, const Name& nam { 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 0b6346bf..913c74ff 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 @@ CommandAuthenticator::processConfig(const ConfigSection& section, bool isDryRun, } 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 @@ CommandAuthenticator::processConfig(const ConfigSection& section, bool isDryRun, certfile = authSection.get("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 @@ CommandAuthenticator::processConfig(const ConfigSection& section, bool isDryRun, path certfilePath = absolute(certfile, path(filename).parent_path()); cert = ndn::io::load(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 @@ CommandAuthenticator::processConfig(const ConfigSection& section, bool isDryRun, 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 @@ CommandAuthenticator::processConfig(const ConfigSection& section, bool isDryRun, 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 @@ CommandAuthenticator::processConfig(const ConfigSection& section, bool isDryRun, 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 6ed3af14..732074b5 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 @@ onConfig(const ConfigSection& section, bool isDryRun, const std::string&) if (i.first == "user") { try { user = i.second.get_value("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("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 678b6e55..e5383a4a 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 @@ TablesConfigSection::processConfig(const ConfigSection& section, bool isDryRun) std::string policyName = csPolicyNode->get_value(); 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 @@ TablesConfigSection::processConfig(const ConfigSection& section, bool isDryRun) std::string policyName = unsolicitedDataPolicyNode->get_value(); 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 @@ TablesConfigSection::processStrategyChoiceSection(const ConfigSection& section, Name strategy(prefixAndStrategy.second.get_value()); if (!Strategy::canCreate(strategy)) { - BOOST_THROW_EXCEPTION(ConfigFile::Error( - "Unknown strategy \"" + prefixAndStrategy.second.get_value() + - "\" for prefix \"" + prefix.toUri() + "\" in \"strategy_choice\" section")); + NDN_THROW(ConfigFile::Error( + "Unknown strategy '" + prefixAndStrategy.second.get_value() + + "' 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 @@ TablesConfigSection::processStrategyChoiceSection(const ConfigSection& section, 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 @@ TablesConfigSection::processNetworkRegionSection(const ConfigSection& section, b 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 144e68e5..a5bd9f88 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 @@ DeadNonceList::DeadNonceList(const time::nanoseconds& lifetime) , 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 1d6328c7..574b5f9d 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 @@ FibUpdater::onUpdateError(const FibUpdate update, } } 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 d09420e4..4477ebc4 100644 --- a/rib/rib-manager.cpp +++ b/rib/rib-manager.cpp @@ -108,12 +108,12 @@ RibManager::enableLocalFields() { m_nfdController.start( 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 @@ RibManager::registerTopPrefix(const Name& topPrefix) 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 a91a93ea..35c092d4 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 @@ makeLocalNfdTransport(const ConfigSection& config) return make_shared("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 @@ Service::Service(ndn::KeyChain& keyChain, shared_ptr localNfdTra , 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& 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 @@ Service::checkConfig(const ConfigSection& section, const std::string& filename) 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 @@ Service::applyConfig(const ConfigSection& section, const std::string& filename) 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 f764125d..7efedfdb 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 @@ protected: virtual unique_ptr 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 - 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 @@ protected: 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 088b3003..0c10276c 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 @@ BOOST_FIXTURE_TEST_CASE(CreateChannel, UdpFactoryMcastFixture) 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 @@ BOOST_FIXTURE_TEST_CASE(CreateChannel, UdpFactoryMcastFixture) [] (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 @@ BOOST_FIXTURE_TEST_CASE(CreateMulticastFaceV4, UdpFactoryMcastFixture) [] (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 @@ BOOST_FIXTURE_TEST_CASE(CreateMulticastFaceV4, UdpFactoryMcastFixture) [] (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 @@ BOOST_FIXTURE_TEST_CASE(CreateMulticastFaceV6, UdpFactoryMcastFixture) [] (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 @@ BOOST_FIXTURE_TEST_CASE(CreateMulticastFaceV6, UdpFactoryMcastFixture) [] (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 4045540c..0da7b841 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 namespace nfd { @@ -54,7 +55,7 @@ choose(Forwarder& forwarder, const Name& prefix = "/", StrategyChoice& sc = forwarder.getStrategyChoice(); auto insertRes = sc.insert(prefix, instanceName); if (!insertRes) { - BOOST_THROW_EXCEPTION(std::invalid_argument(boost::lexical_cast(insertRes))); + NDN_THROW(std::invalid_argument(boost::lexical_cast(insertRes))); } return dynamic_cast(sc.findEffectiveStrategy(prefix)); } diff --git a/tests/daemon/mgmt/general-config-section.t.cpp b/tests/daemon/mgmt/general-config-section.t.cpp index a12b09b5..98b9458c 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 @@ BOOST_AUTO_TEST_CASE(InvalidUserConfig) 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 @@ BOOST_AUTO_TEST_CASE(InvalidGroupConfig) 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 ab361fd7..e9b27623 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 @@ IdentityManagementFixture::getIdentityCertificateBase64(const Name& identity, bo } 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 9f8f4dcd..f31ec9c1 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 @@ LimitedIo::afterOp() m_reason = EXCEED_OPS; getGlobalIoService().stop(); if (m_uttf != nullptr) { - BOOST_THROW_EXCEPTION(StopException()); + NDN_THROW(StopException()); } } } @@ -109,7 +109,7 @@ LimitedIo::afterTimeout() 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 007a87be..5745c03c 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 @@ private: } 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 @@ private: 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 717853f5..744608f1 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 @@ CongestionMarkStrategy::CongestionMarkStrategy(Forwarder& forwarder, const Name& 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 @@ CongestionMarkStrategy::CongestionMarkStrategy(Forwarder& forwarder, const Name& 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(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 f0992954..574ef17f 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 @@ parseSrvRr(const QueryAnswer& queryAnswer, int answerSize) 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 @@ parseSrvRr(const QueryAnswer& queryAnswer, int answerSize) 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(&blob[sizeof(rechdr)]); @@ -106,7 +106,7 @@ parseSrvRr(const QueryAnswer& queryAnswer, int answerSize) 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 @@ querySrvRr(const std::string& fqdn) 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 @@ querySrvRrSearch() 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 abb934ff..879ea8ea 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 @@ NdnFchDiscovery::doStart() 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 @@ NdnFchDiscovery::doStart() 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 @@ NdnFchDiscovery::doStart() std::getline(responseStream, statusMessage); if (!static_cast(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 @@ NdnFchDiscovery::doStart() 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 2e1e0482..0569b244 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 @@ void 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 9dce67a6..4d92ca7b 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 @@ CommandDefinition::parse(const std::vector& tokens, size_t start) c 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 @@ CommandDefinition::parse(const std::vector& tokens, size_t start) c } 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 @@ CommandDefinition::parse(const std::vector& tokens, size_t start) c 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 @@ CommandDefinition::parse(const std::vector& tokens, size_t start) c 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 @@ CommandDefinition::parse(const std::vector& tokens, size_t start) c 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 @@ parseBoolean(const std::string& s) 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 @@ parseFacePersistency(const std::string& s) 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 @@ CommandDefinition::parseValue(ArgValueType valueType, const std::string& token) // boost::lexical_cast will accept negative number int64_t v = boost::lexical_cast(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(v); } diff --git a/tools/nfdc/command-parser.cpp b/tools/nfdc/command-parser.cpp index a2012723..9153890a 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 @@ CommandParser::parse(const std::vector& tokens, ParseMode mode) con auto i = m_commands.find({noun, verb}); if (i == m_commands.end() || (i->second->modes & static_cast(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 01ad5c6e..aa3cdf1a 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 @@ parseReportFormat(const std::string& s) 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 @@ void StatusReport::formatXml(std::ostream& os) const { xml::printHeader(os); - for (const unique_ptr& module : sections) { + for (const auto& module : sections) { module->formatStatusXml(os); } xml::printFooter(os); @@ -94,7 +94,7 @@ StatusReport::formatXml(std::ostream& os) const void StatusReport::formatText(std::ostream& os) const { - for (const unique_ptr& module : sections) { + for (const auto& module : sections) { module->formatStatusText(os); } }