From 8eb7066b8e669ce5517cca6cdd47f07028482ab2 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 19 Apr 2012 21:44:59 +0000 Subject: 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 --- cpp/src/qpid/ha/ReplicateLevel.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'cpp/src/qpid/ha/ReplicateLevel.cpp') 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 #include @@ -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]; } -- cgit v1.2.1