Skip to content

Commit

Permalink
Fleshed out an exception message.
Browse files Browse the repository at this point in the history
  • Loading branch information
pcolby committed May 11, 2014
1 parent 3a04abb commit 29eda8d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions include/pcp-cpp/cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "exception.hpp"
#include "types.hpp"

#include <sstream>

PCP_CPP_BEGIN_NAMESPACE

namespace pcp {
Expand Down Expand Up @@ -89,7 +91,10 @@ lookup_result_type<Type> lookup(const pmInDom indom,
throw pcp::exception(result.status);
}
if ((flags & require_active) && (result.status != PMDA_CACHE_ACTIVE)) {
throw pcp::exception(result.status, "not active"); ///< @todo Better message.
std::ostringstream message;
message << "Cache entry " << indom << ':' << instance_id
<< " (\"" << result.name << "\") inactive";
throw pcp::exception(result.status, message.str());
}
result.instance_id = instance_id;
result.opaque = static_cast<Type>(opaque);
Expand Down Expand Up @@ -125,7 +130,10 @@ lookup_result_type<Type> lookup(const pmInDom indom, const std::string &name,
throw pcp::exception(result.status);
}
if ((flags & require_active) && (result.status != PMDA_CACHE_ACTIVE)) {
throw pcp::exception(result.status, "not active"); ///< @todo Better message.
std::ostringstream message;
message << "Cache entry " << indom << ':' << result.instance_id
<< " (\"" << name << "\") inactive";
throw pcp::exception(result.status, message.str());
}
result.name = NULL;
result.opaque = static_cast<Type>(opaque);
Expand Down Expand Up @@ -164,7 +172,10 @@ lookup_result_type<Type> lookup(const pmInDom indom, const std::string &name,
throw pcp::exception(result.status);
}
if ((flags & require_active) && (result.status != PMDA_CACHE_ACTIVE)) {
throw pcp::exception(result.status, "not active"); ///< @todo Better message.
std::ostringstream message;
message << "Cache entry " << indom << ':' << result.instance_id
<< " (\"" << name << "\":\"" << key << "\") inactive";
throw pcp::exception(result.status, message.str());
}
result.opaque = static_cast<Type>(opaque);
return result;
Expand Down

0 comments on commit 29eda8d

Please sign in to comment.