Replace all uses of BOOST_THROW_EXCEPTION with NDN_THROW
Refs: #4834
Change-Id: Ic63e276b7174f3af12af67daa9cad4586b43b9e6
diff --git a/tools/ndn-nac/main.cpp b/tools/ndn-nac/main.cpp
index 0ebe9ed..6858532 100644
--- a/tools/ndn-nac/main.cpp
+++ b/tools/ndn-nac/main.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-2020, Regents of the University of California
*
* NAC library is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -20,12 +20,13 @@
#include "ndn-nac.hpp"
#include "version.hpp"
-#include <boost/exception/get_error_info.hpp>
+#include <boost/exception/diagnostic_information.hpp>
+
#include <ndn-cxx/util/logger.hpp>
NDN_LOG_INIT(nac.Cmd);
-std::string nac_helper = R"STR(
+const char NAC_HELP_TEXT[] = R"STR(
help Show all commands
version Show version and exit
dump-kek Dump KEK
@@ -36,39 +37,28 @@
main(int argc, char** argv)
{
if (argc < 2) {
- std::cerr << nac_helper << std::endl;
- return 1;
+ std::cerr << NAC_HELP_TEXT << std::endl;
+ return 2;
}
using namespace ndn::nac;
std::string command(argv[1]);
try {
- if (command == "help") { std::cout << nac_helper << std::endl; }
+ if (command == "help") { std::cout << NAC_HELP_TEXT << std::endl; }
else if (command == "version") { std::cout << NDN_NAC_VERSION_BUILD_STRING << std::endl; }
else if (command == "dump-kek") { return nac_dump_kek(argc - 1, argv + 1); }
else if (command == "add-member") { return nac_add_member(argc - 1, argv + 1); }
else {
- std::cerr << nac_helper << std::endl;
- return 1;
+ std::cerr << "ERROR: Unknown command '" << command << "'\n"
+ << "\n"
+ << NAC_HELP_TEXT << std::endl;
+ return 2;
}
}
catch (const std::exception& e) {
-
- std::cerr << "ERROR: " << e.what();
-
- std::ostringstream extendedError;
- const char* const* file = boost::get_error_info<boost::throw_file>(e);
- const int* line = boost::get_error_info<boost::throw_line>(e);
- const char* const* func = boost::get_error_info<boost::throw_function>(e);
- if (file && line) {
- extendedError << " [from " << *file << ":" << *line;
- if (func) {
- extendedError << " in " << *func;
- }
- extendedError << "]";
- }
- NDN_LOG_ERROR(e.what() << extendedError.str());
+ std::cerr << "ERROR: " << e.what() << std::endl;
+ NDN_LOG_ERROR(boost::diagnostic_information(e));
return 1;
}