change BOOST_THROW to NDN_THROW
Change-Id: Ic5a0192302dd2965258d616fe163f3539b2104ea
diff --git a/src/ca-storage/ca-memory.cpp b/src/ca-storage/ca-memory.cpp
index e08a822..206f431 100644
--- a/src/ca-storage/ca-memory.cpp
+++ b/src/ca-storage/ca-memory.cpp
@@ -40,7 +40,7 @@
{
auto search = m_requests.find(requestId);
if (search == m_requests.end()) {
- BOOST_THROW_EXCEPTION(std::runtime_error("Request " + requestId + " doest not exists"));
+ NDN_THROW(std::runtime_error("Request " + requestId + " doest not exists"));
}
return search->second;
}
@@ -53,7 +53,7 @@
m_requests[request.m_requestId] = request;
}
else {
- BOOST_THROW_EXCEPTION(std::runtime_error("Request " + request.m_requestId + " already exists"));
+ NDN_THROW(std::runtime_error("Request " + request.m_requestId + " already exists"));
}
}
diff --git a/src/ca-storage/ca-sqlite.cpp b/src/ca-storage/ca-sqlite.cpp
index d3f1183..e9905d6 100644
--- a/src/ca-storage/ca-sqlite.cpp
+++ b/src/ca-storage/ca-sqlite.cpp
@@ -88,7 +88,7 @@
#endif
);
if (result != SQLITE_OK)
- BOOST_THROW_EXCEPTION(std::runtime_error("CaSqlite DB cannot be opened/created: " + dbDir.string()));
+ NDN_THROW(std::runtime_error("CaSqlite DB cannot be opened/created: " + dbDir.string()));
// initialize database specific tables
char* errorMessage = nullptr;
@@ -96,7 +96,7 @@
nullptr, nullptr, &errorMessage);
if (result != SQLITE_OK && errorMessage != nullptr) {
sqlite3_free(errorMessage);
- BOOST_THROW_EXCEPTION(std::runtime_error("CaSqlite DB cannot be initialized"));
+ NDN_THROW(std::runtime_error("CaSqlite DB cannot be initialized"));
}
}
@@ -139,7 +139,7 @@
}
}
else {
- BOOST_THROW_EXCEPTION(std::runtime_error("Request " + requestId + " cannot be fetched from database"));
+ NDN_THROW(std::runtime_error("Request " + requestId + " cannot be fetched from database"));
}
}
@@ -168,7 +168,7 @@
statement.bind(11, request.m_challengeState->m_remainingTime.count());
}
if (statement.step() != SQLITE_DONE) {
- BOOST_THROW_EXCEPTION(std::runtime_error("Request " + request.m_requestId + " cannot be added to database"));
+ NDN_THROW(std::runtime_error("Request " + request.m_requestId + " cannot be added to database"));
}
}
diff --git a/src/configuration.cpp b/src/configuration.cpp
index 872204f..c9b1694 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -33,7 +33,7 @@
// CA prefix
m_caPrefix = Name(configJson.get(CONFIG_CA_PREFIX, ""));
if (m_caPrefix.empty()) {
- BOOST_THROW_EXCEPTION(std::runtime_error("Cannot parse ca-prefix from the config file"));
+ NDN_THROW(std::runtime_error("Cannot parse ca-prefix from the config file"));
}
// CA info
m_caInfo = configJson.get(CONFIG_CA_INFO, "");
@@ -49,7 +49,7 @@
auto probeParameter = item.second.get(CONFIG_PROBE_PARAMETER, "");
probeParameter = boost::algorithm::to_lower_copy(probeParameter);
if (probeParameter == "") {
- BOOST_THROW_EXCEPTION(std::runtime_error("Probe parameter key cannot be empty."));
+ NDN_THROW(std::runtime_error("Probe parameter key cannot be empty."));
}
m_probeParameterKeys.push_back(probeParameter);
}
@@ -62,10 +62,10 @@
auto challengeType = item.second.get(CONFIG_CHALLENGE, "");
challengeType = boost::algorithm::to_lower_copy(challengeType);
if (challengeType == "") {
- BOOST_THROW_EXCEPTION(std::runtime_error("Challenge type canont be empty."));
+ NDN_THROW(std::runtime_error("Challenge type canont be empty."));
}
if (!ChallengeModule::isChallengeSupported(challengeType)) {
- BOOST_THROW_EXCEPTION(std::runtime_error("Challenge " + challengeType + " is not supported."));
+ NDN_THROW(std::runtime_error("Challenge " + challengeType + " is not supported."));
}
m_supportedChallenges.push_back(challengeType);
}
@@ -121,14 +121,14 @@
boost::property_tree::read_json(fileName, configJson);
}
catch (const std::exception& error) {
- BOOST_THROW_EXCEPTION(std::runtime_error("Failed to parse configuration file " + fileName + ", " + error.what()));
+ NDN_THROW(std::runtime_error("Failed to parse configuration file " + fileName + ", " + error.what()));
}
if (configJson.begin() == configJson.end()) {
- BOOST_THROW_EXCEPTION(std::runtime_error("No JSON configuration found in file: " + fileName));
+ NDN_THROW(std::runtime_error("No JSON configuration found in file: " + fileName));
}
m_caItem.parse(configJson);
if (m_caItem.m_supportedChallenges.size() == 0) {
- BOOST_THROW_EXCEPTION(std::runtime_error("At least one challenge should be specified."));
+ NDN_THROW(std::runtime_error("At least one challenge should be specified."));
}
// parse redirection section if appears
m_redirection = boost::none;
@@ -138,7 +138,7 @@
auto caPrefixStr = item.second.get(CONFIG_CA_PREFIX, "");
auto caCertStr = item.second.get(CONFIG_CERTIFICATE, "");
if (caCertStr == "") {
- BOOST_THROW_EXCEPTION(std::runtime_error("Redirect-to item's ca-prefix or certificate cannot be empty."));
+ NDN_THROW(std::runtime_error("Redirect-to item's ca-prefix or certificate cannot be empty."));
}
std::istringstream ss(caCertStr);
auto caCert = io::load<security::Certificate>(ss);
@@ -155,7 +155,7 @@
for (const auto& item : *nameAssignmentItems) {
auto func = NameAssignmentFunc::createNameAssignmentFunc(item.first, item.second.data());
if (func == nullptr) {
- BOOST_THROW_EXCEPTION(std::runtime_error("Error on creating name assignment function"));
+ NDN_THROW(std::runtime_error("Error on creating name assignment function"));
}
m_nameAssignmentFuncs.push_back(std::move(func));
}
@@ -170,10 +170,10 @@
boost::property_tree::read_json(fileName, configJson);
}
catch (const std::exception& error) {
- BOOST_THROW_EXCEPTION(std::runtime_error("Failed to parse configuration file " + fileName + ", " + error.what()));
+ NDN_THROW(std::runtime_error("Failed to parse configuration file " + fileName + ", " + error.what()));
}
if (configJson.begin() == configJson.end()) {
- BOOST_THROW_EXCEPTION(std::runtime_error("No JSON configuration found in file: " + fileName));
+ NDN_THROW(std::runtime_error("No JSON configuration found in file: " + fileName));
}
load(configJson);
}
@@ -187,7 +187,7 @@
CaProfile caItem;
caItem.parse(item.second);
if (caItem.m_cert == nullptr) {
- BOOST_THROW_EXCEPTION(std::runtime_error("No CA certificate is loaded from JSON configuration."));
+ NDN_THROW(std::runtime_error("No CA certificate is loaded from JSON configuration."));
}
m_caItems.push_back(std::move(caItem));
}
diff --git a/src/crypto-support/crypto-helper.cpp b/src/crypto-support/crypto-helper.cpp
index 916bee4..2920fdb 100644
--- a/src/crypto-support/crypto-helper.cpp
+++ b/src/crypto-support/crypto-helper.cpp
@@ -378,7 +378,7 @@
handleErrors(const std::string& errorInfo)
{
NDN_LOG_DEBUG("Error in CRYPTO SUPPORT " << errorInfo);
- BOOST_THROW_EXCEPTION(CryptoError("Error in CRYPTO SUPPORT: " + errorInfo));
+ NDN_THROW(CryptoError("Error in CRYPTO SUPPORT: " + errorInfo));
}
} // namespace ndncert
diff --git a/src/identity-challenge/challenge-credential.cpp b/src/identity-challenge/challenge-credential.cpp
index 9cb54a6..b8e493f 100644
--- a/src/identity-challenge/challenge-credential.cpp
+++ b/src/identity-challenge/challenge-credential.cpp
@@ -52,12 +52,12 @@
boost::property_tree::read_json(m_configFile, config);
}
catch (const boost::property_tree::info_parser_error& error) {
- BOOST_THROW_EXCEPTION(std::runtime_error("Failed to parse configuration file " + m_configFile +
+ NDN_THROW(std::runtime_error("Failed to parse configuration file " + m_configFile +
" " + error.message() + " line " + std::to_string(error.line())));
}
if (config.begin() == config.end()) {
- BOOST_THROW_EXCEPTION(std::runtime_error("Error processing configuration file: " + m_configFile + " no data"));
+ NDN_THROW(std::runtime_error("Error processing configuration file: " + m_configFile + " no data"));
}
m_trustAnchors.clear();
@@ -132,7 +132,7 @@
result.push_back(std::make_tuple(PARAMETER_KEY_PROOF_OF_PRIVATE_KEY, "Please sign a Data packet with request ID as the content."));
return result;
}
- BOOST_THROW_EXCEPTION(std::runtime_error("Unexpected status or challenge status."));
+ NDN_THROW(std::runtime_error("Unexpected status or challenge status."));
}
Block
@@ -142,7 +142,7 @@
Block request = makeEmptyBlock(tlv_encrypted_payload);
if (status == Status::BEFORE_CHALLENGE) {
if (params.size() != 2) {
- BOOST_THROW_EXCEPTION(std::runtime_error("Wrong parameter provided."));
+ NDN_THROW(std::runtime_error("Wrong parameter provided."));
}
request.push_back(makeStringBlock(tlv_selected_challenge, CHALLENGE_TYPE));
for (const auto& item : params) {
@@ -160,12 +160,12 @@
request.push_back(valueBlock);
}
else {
- BOOST_THROW_EXCEPTION(std::runtime_error("Wrong parameter provided."));
+ NDN_THROW(std::runtime_error("Wrong parameter provided."));
}
}
}
else {
- BOOST_THROW_EXCEPTION(std::runtime_error("Unexpected status or challenge status."));
+ NDN_THROW(std::runtime_error("Unexpected status or challenge status."));
}
request.encode();
return request;
diff --git a/src/identity-challenge/challenge-email.cpp b/src/identity-challenge/challenge-email.cpp
index 39dd162..f08025b 100644
--- a/src/identity-challenge/challenge-email.cpp
+++ b/src/identity-challenge/challenge-email.cpp
@@ -115,7 +115,7 @@
result.push_back(std::make_tuple(PARAMETER_KEY_CODE, "Incorrect code, please try again"));
}
else {
- BOOST_THROW_EXCEPTION(std::runtime_error("Unexpected status or challenge status."));
+ NDN_THROW(std::runtime_error("Unexpected status or challenge status."));
}
return result;
}
@@ -126,7 +126,7 @@
Block request = makeEmptyBlock(tlv_encrypted_payload);
if (status == Status::BEFORE_CHALLENGE) {
if (params.size() != 1 || std::get<0>(params[0]) != PARAMETER_KEY_EMAIL) {
- BOOST_THROW_EXCEPTION(std::runtime_error("Wrong parameter provided."));
+ NDN_THROW(std::runtime_error("Wrong parameter provided."));
}
request.push_back(makeStringBlock(tlv_selected_challenge, CHALLENGE_TYPE));
request.push_back(makeStringBlock(tlv_parameter_key, PARAMETER_KEY_EMAIL));
@@ -134,14 +134,14 @@
}
else if (status == Status::CHALLENGE && (challengeStatus == NEED_CODE || challengeStatus == WRONG_CODE)) {
if (params.size() != 1 || std::get<0>(params[0]) != PARAMETER_KEY_CODE) {
- BOOST_THROW_EXCEPTION(std::runtime_error("Wrong parameter provided."));
+ NDN_THROW(std::runtime_error("Wrong parameter provided."));
}
request.push_back(makeStringBlock(tlv_selected_challenge, CHALLENGE_TYPE));
request.push_back(makeStringBlock(tlv_parameter_key, PARAMETER_KEY_CODE));
request.push_back(makeStringBlock(tlv_parameter_value, std::get<1>(params[0])));
}
else {
- BOOST_THROW_EXCEPTION(std::runtime_error("Unexpected status or challenge status."));
+ NDN_THROW(std::runtime_error("Unexpected status or challenge status."));
}
request.encode();
return request;
diff --git a/src/identity-challenge/challenge-pin.cpp b/src/identity-challenge/challenge-pin.cpp
index d7416c5..04bd153 100644
--- a/src/identity-challenge/challenge-pin.cpp
+++ b/src/identity-challenge/challenge-pin.cpp
@@ -98,7 +98,7 @@
result.push_back(std::make_tuple(PARAMETER_KEY_CODE, "Incorrect PIN code, please try again"));
}
else {
- BOOST_THROW_EXCEPTION(std::runtime_error("Unexpected status or challenge status."));
+ NDN_THROW(std::runtime_error("Unexpected status or challenge status."));
}
return result;
}
@@ -112,14 +112,14 @@
}
else if (status == Status::CHALLENGE && (challengeStatus == NEED_CODE || challengeStatus == WRONG_CODE)) {
if (params.size() != 1 || std::get<0>(params[0]) != PARAMETER_KEY_CODE) {
- BOOST_THROW_EXCEPTION(std::runtime_error("Wrong parameter provided."));
+ NDN_THROW(std::runtime_error("Wrong parameter provided."));
}
request.push_back(makeStringBlock(tlv_selected_challenge, CHALLENGE_TYPE));
request.push_back(makeStringBlock(tlv_parameter_key, PARAMETER_KEY_CODE));
request.push_back(makeStringBlock(tlv_parameter_value, std::get<1>(params[0])));
}
else {
- BOOST_THROW_EXCEPTION(std::runtime_error("Unexpected status or challenge status."));
+ NDN_THROW(std::runtime_error("Unexpected status or challenge status."));
}
request.encode();
return request;
diff --git a/src/protocol-detail/probe.cpp b/src/protocol-detail/probe.cpp
index 517a15e..04b4bc9 100644
--- a/src/protocol-detail/probe.cpp
+++ b/src/protocol-detail/probe.cpp
@@ -84,7 +84,7 @@
for (const auto& subBlock: item.elements()) {
if (subBlock.type() == tlv::Name) {
if (!elementName.empty()) {
- BOOST_THROW_EXCEPTION(std::runtime_error("Invalid probe format"));
+ NDN_THROW(std::runtime_error("Invalid probe format"));
}
elementName.wireDecode(subBlock);
} else if (subBlock.type() == tlv_max_suffix_length) {
@@ -92,7 +92,7 @@
}
}
if (elementName.empty()) {
- BOOST_THROW_EXCEPTION(std::runtime_error("Invalid probe format"));
+ NDN_THROW(std::runtime_error("Invalid probe format"));
}
availableNames.emplace_back(elementName, maxSuffixLength);
}
diff --git a/src/requester.cpp b/src/requester.cpp
index 16665a3..9bafeb8 100644
--- a/src/requester.cpp
+++ b/src/requester.cpp
@@ -67,7 +67,7 @@
auto caItem = INFO::decodeDataContent(reply.getContent());
if (!security::verifySignature(reply, *caItem.m_cert)) {
NDN_LOG_ERROR("Cannot verify replied Data packet signature.");
- BOOST_THROW_EXCEPTION(std::runtime_error("Cannot verify replied Data packet signature."));
+ NDN_THROW(std::runtime_error("Cannot verify replied Data packet signature."));
}
return caItem;
}
@@ -81,7 +81,7 @@
caItem.m_cert = std::make_shared<security::Certificate>(certBlock);
if (caItem.m_cert->getFullName() != caCertFullName) {
NDN_LOG_ERROR("Ca profile does not match the certificate information offered by the original CA.");
- BOOST_THROW_EXCEPTION(std::runtime_error("Cannot verify replied Data packet signature."));
+ NDN_THROW(std::runtime_error("Cannot verify replied Data packet signature."));
}
return onCaProfileResponse(reply);
}
@@ -104,7 +104,7 @@
{
if (!security::verifySignature(reply, *ca.m_cert)) {
NDN_LOG_ERROR("Cannot verify replied Data packet signature.");
- BOOST_THROW_EXCEPTION(std::runtime_error("Cannot verify replied Data packet signature."));
+ NDN_THROW(std::runtime_error("Cannot verify replied Data packet signature."));
return;
}
processIfError(reply);
@@ -193,7 +193,7 @@
{
if (!security::verifySignature(reply, *state.m_caItem.m_cert)) {
NDN_LOG_ERROR("Cannot verify replied Data packet signature.");
- BOOST_THROW_EXCEPTION(std::runtime_error("Cannot verify replied Data packet signature."));
+ NDN_THROW(std::runtime_error("Cannot verify replied Data packet signature."));
}
processIfError(reply);
@@ -216,7 +216,7 @@
{
auto challenge = ChallengeModule::createChallengeModule(challengeSelected);
if (challenge == nullptr) {
- BOOST_THROW_EXCEPTION(std::runtime_error("The challenge selected is not supported by your current version of NDNCERT."));
+ NDN_THROW(std::runtime_error("The challenge selected is not supported by your current version of NDNCERT."));
}
state.m_challengeType = challengeSelected;
return challenge->getRequestedParameterList(state.m_status, state.m_challengeStatus);
@@ -227,11 +227,11 @@
std::vector<std::tuple<std::string, std::string>>&& parameters)
{
if (state.m_challengeType == "") {
- BOOST_THROW_EXCEPTION(std::runtime_error("The challenge has not been selected."));
+ NDN_THROW(std::runtime_error("The challenge has not been selected."));
}
auto challenge = ChallengeModule::createChallengeModule(state.m_challengeType);
if (challenge == nullptr) {
- BOOST_THROW_EXCEPTION(std::runtime_error("The challenge selected is not supported by your current version of NDNCERT."));
+ NDN_THROW(std::runtime_error("The challenge selected is not supported by your current version of NDNCERT."));
}
auto challengeParams = challenge->genChallengeRequestTLV(state.m_status, state.m_challengeStatus, std::move(parameters));
@@ -255,7 +255,7 @@
{
if (!security::verifySignature(reply, *state.m_caItem.m_cert)) {
NDN_LOG_ERROR("Cannot verify replied Data packet signature.");
- BOOST_THROW_EXCEPTION(std::runtime_error("Cannot verify replied Data packet signature."));
+ NDN_THROW(std::runtime_error("Cannot verify replied Data packet signature."));
}
processIfError(reply);
auto result = decodeBlockWithAesGcm128(reply.getContent(), state.m_aesKey, (const uint8_t*)"test", strlen("test"));
@@ -281,7 +281,7 @@
}
catch (const std::exception& e) {
NDN_LOG_ERROR("Cannot parse replied certificate ");
- BOOST_THROW_EXCEPTION(std::runtime_error("Cannot parse replied certificate "));
+ NDN_THROW(std::runtime_error("Cannot parse replied certificate "));
return nullptr;
}
}
@@ -315,7 +315,7 @@
NDN_LOG_ERROR("Error info replied from the CA with Error code: " +
errorCodeToString(std::get<0>(errorInfo)) +
" and Error Info: " + std::get<1>(errorInfo));
- BOOST_THROW_EXCEPTION(std::runtime_error("Error info replied from the CA with Error code: " +
+ NDN_THROW(std::runtime_error("Error info replied from the CA with Error code: " +
errorCodeToString(std::get<0>(errorInfo)) +
" and Error Info: " + std::get<1>(errorInfo)));
}