Replace all uses of BOOST_THROW_EXCEPTION with NDN_THROW

Refs: #4834
Change-Id: If2455e1830f310beea434ffb455d960e11c4c2ed
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);
   }
 }