Remove use of deprecated code
Change-Id: I721e9d0f9b41e7a53d75b1fde4a718c349273eeb
Refs: #3988
diff --git a/src/repo.cpp b/src/repo.cpp
index 0ec3837..dcf7007 100644
--- a/src/repo.cpp
+++ b/src/repo.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014, Regents of the University of California.
+ * Copyright (c) 2014-2017, Regents of the University of California.
*
* This file is part of NDN repo-ng (Next generation of NDN repository).
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -31,15 +31,15 @@
std::ifstream fin(configPath.c_str());
if (!fin.is_open())
- throw Repo::Error("failed to open configuration file '"+ configPath +"'");
+ BOOST_THROW_EXCEPTION(Repo::Error("failed to open configuration file '"+ configPath +"'"));
using namespace boost::property_tree;
ptree propertyTree;
try {
read_info(fin, propertyTree);
}
- catch (ptree_error& e) {
- throw Repo::Error("failed to read configuration file '"+ configPath +"'");
+ catch (const ptree_error& e) {
+ BOOST_THROW_EXCEPTION(Repo::Error("failed to read configuration file '"+ configPath +"'"));
}
ptree repoConf = propertyTree.get_child("repo");
@@ -55,8 +55,8 @@
if (it->first == "prefix")
repoConfig.dataPrefixes.push_back(Name(it->second.get_value<std::string>()));
else
- throw Repo::Error("Unrecognized '" + it->first + "' option in 'data' section in "
- "configuration file '"+ configPath +"'");
+ BOOST_THROW_EXCEPTION(Repo::Error("Unrecognized '" + it->first + "' option in 'data' section in "
+ "configuration file '"+ configPath +"'"));
}
ptree commandConf = repoConf.get_child("command");
@@ -67,8 +67,8 @@
if (it->first == "prefix")
repoConfig.repoPrefixes.push_back(Name(it->second.get_value<std::string>()));
else
- throw Repo::Error("Unrecognized '" + it->first + "' option in 'command' section in "
- "configuration file '"+ configPath +"'");
+ BOOST_THROW_EXCEPTION(Repo::Error("Unrecognized '" + it->first + "' option in 'command' section in "
+ "configuration file '"+ configPath +"'"));
}
ptree tcpBulkInsert = repoConf.get_child("tcp_bulk_insert");
@@ -92,15 +92,16 @@
port = it->second.get_value<std::string>();
}
else
- throw Repo::Error("Unrecognized '" + it->first + "' option in 'tcp_bulk_insert' section in "
- "configuration file '"+ configPath +"'");
+ BOOST_THROW_EXCEPTION(Repo::Error("Unrecognized '" + it->first + "' option in 'tcp_bulk_insert' section in "
+ "configuration file '"+ configPath +"'"));
}
if (isTcpBulkEnabled) {
repoConfig.tcpBulkInsertEndpoints.push_back(std::make_pair(host, port));
}
- if (repoConf.get<std::string>("storage.method") != "sqlite")
- throw Repo::Error("Only 'sqlite' storage method is supported");
+ if (repoConf.get<std::string>("storage.method") != "sqlite") {
+ BOOST_THROW_EXCEPTION(Repo::Error("Only 'sqlite' storage method is supported"));
+ }
repoConfig.dbPath = repoConf.get<std::string>("storage.path");