table: StrategyChoice::insert return value includes error description
The error description is used in the response to a strategy-choice/set
management command failure.
refs #3868
Change-Id: I14e0eb4dc311806a90ebfe60fa17177d2809d104
diff --git a/tests/daemon/fw/choose-strategy.hpp b/tests/daemon/fw/choose-strategy.hpp
index 9ecc54b..4045540 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-2016, Regents of the University of California,
+ * Copyright (c) 2014-2017, 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 <boost/lexical_cast.hpp>
namespace nfd {
namespace fw {
@@ -41,7 +42,7 @@
* \param forwarder the forwarder
* \param prefix namespace to choose the strategy for
* \param instanceName strategy instance name; the strategy must already be registered
- * \throw std::invalid_argument cannot find strategy by instanceName
+ * \throw std::invalid_argument cannot create strategy by instanceName
* \throw std::bad_cast strategy type is incompatible with S
* \return a reference to the strategy
*/
@@ -51,9 +52,9 @@
const Name& instanceName = S::getStrategyName())
{
StrategyChoice& sc = forwarder.getStrategyChoice();
- bool isInserted = sc.insert(prefix, instanceName);
- if (!isInserted) {
- BOOST_THROW_EXCEPTION(std::invalid_argument("cannot create strategy"));
+ auto insertRes = sc.insert(prefix, instanceName);
+ if (!insertRes) {
+ BOOST_THROW_EXCEPTION(std::invalid_argument(boost::lexical_cast<std::string>(insertRes)));
}
return dynamic_cast<S&>(sc.findEffectiveStrategy(prefix));
}