summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/ha/ReplicateLevel.cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2012-04-19 21:44:59 +0000
committerAlan Conway <aconway@apache.org>2012-04-19 21:44:59 +0000
commit8eb7066b8e669ce5517cca6cdd47f07028482ab2 (patch)
tree7deb9f9c96cc08ddcd7b1b430b6e84a135798a75 /cpp/src/qpid/ha/ReplicateLevel.cpp
parent1b37e39741bc44392fd5adbfd1b2cc4ccc643502 (diff)
downloadqpid-python-8eb7066b8e669ce5517cca6cdd47f07028482ab2.tar.gz
QPID-3606: More consistent logging and error handling for HA code.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1328124 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/ha/ReplicateLevel.cpp')
-rw-r--r--cpp/src/qpid/ha/ReplicateLevel.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/cpp/src/qpid/ha/ReplicateLevel.cpp b/cpp/src/qpid/ha/ReplicateLevel.cpp
index 2c3614bb63..4981577225 100644
--- a/cpp/src/qpid/ha/ReplicateLevel.cpp
+++ b/cpp/src/qpid/ha/ReplicateLevel.cpp
@@ -20,6 +20,7 @@
*/
#include "ReplicateLevel.h"
#include "qpid/Exception.h"
+#include "qpid/Msg.h"
#include <iostream>
#include <assert.h>
@@ -31,7 +32,7 @@ using namespace std;
// Note replicateLevel is called during plugin-initialization which
// happens in the static construction phase so these constants need
// to be POD, they can't be class objects
-//
+//
namespace {
const char* S_NONE="none";
const char* S_CONFIGURATION="configuration";
@@ -47,17 +48,15 @@ bool replicateLevel(const string& level, ReplicateLevel& out) {
ReplicateLevel replicateLevel(const string& level) {
ReplicateLevel rl;
- if (!replicateLevel(level, rl)) {
- assert(0);
+ if (!replicateLevel(level, rl))
throw Exception("Invalid value for replication level: "+level);
- }
return rl;
}
string str(ReplicateLevel l) {
const char* names[] = { S_NONE, S_CONFIGURATION, S_ALL };
- assert(l >= RL_NONE);
- assert(l <= RL_ALL);
+ if (l > RL_ALL)
+ throw Exception(QPID_MSG("Invalid value for replication level: " << l));
return names[l];
}