[rhmessaging-commits] rhmessaging commits: r1340 - in store/trunk/cpp: tests/jrnl and 1 other directory.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Tue Nov 20 13:44:46 EST 2007


Author: kpvdr
Date: 2007-11-20 13:44:46 -0500 (Tue, 20 Nov 2007)
New Revision: 1340

Modified:
   store/trunk/cpp/lib/jrnl/jerrno.cpp
   store/trunk/cpp/lib/jrnl/jerrno.hpp
   store/trunk/cpp/lib/jrnl/jexception.cpp
   store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp
Log:
Additional tidy-up for jexception class and an additional error code for jerrno.

Modified: store/trunk/cpp/lib/jrnl/jerrno.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jerrno.cpp	2007-11-20 13:58:23 UTC (rev 1339)
+++ store/trunk/cpp/lib/jrnl/jerrno.cpp	2007-11-20 18:44:46 UTC (rev 1340)
@@ -58,6 +58,7 @@
 const u_int32_t jerrno::JERR_JCNTL_AIOCMPLWAIT  = 0x0202;
 const u_int32_t jerrno::JERR_JCNTL_UNKNOWNMAGIC = 0x0203;
 const u_int32_t jerrno::JERR_JCNTL_NOTRECOVERED = 0x0204;
+const u_int32_t jerrno::JERR_JCNTL_RECOVERJFULL = 0x0205;
 
 // class jdir
 const u_int32_t jerrno::JERR_JDIR_NOTDIR        = 0x0300;
@@ -139,6 +140,8 @@
     _err_map[JERR_JCNTL_UNKNOWNMAGIC] = "JERR_JCNTL_UNKNOWNMAGIC: Found record with unknown magic.";
     _err_map[JERR_JCNTL_NOTRECOVERED] = "JERR_JCNTL_NOTRECOVERED: "
             "Operation requires recover() to be run first.";
+    _err_map[JERR_JCNTL_RECOVERJFULL] = "JERR_JCNTL_RECOVERJFULL: "
+            "Journal data files full, cannot write.";
 
     // class jdir
     _err_map[JERR_JDIR_NOTDIR] = "JERR_JDIR_NOTDIR: Directory name exists but is not a directory.";

Modified: store/trunk/cpp/lib/jrnl/jerrno.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jerrno.hpp	2007-11-20 13:58:23 UTC (rev 1339)
+++ store/trunk/cpp/lib/jrnl/jerrno.hpp	2007-11-20 18:44:46 UTC (rev 1340)
@@ -75,6 +75,7 @@
         static const u_int32_t JERR_JCNTL_AIOCMPLWAIT;  ///< Timeout waiting for AIOs to complete
         static const u_int32_t JERR_JCNTL_UNKNOWNMAGIC; ///< Found record with unknown magic
         static const u_int32_t JERR_JCNTL_NOTRECOVERED; ///< Req' recover() to be called first
+        static const u_int32_t JERR_JCNTL_RECOVERJFULL; ///< Journal data files full, cannot write
 
         // class jdir
         static const u_int32_t JERR_JDIR_NOTDIR;        ///< Exists but is not a directory

Modified: store/trunk/cpp/lib/jrnl/jexception.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jexception.cpp	2007-11-20 13:58:23 UTC (rev 1339)
+++ store/trunk/cpp/lib/jrnl/jexception.cpp	2007-11-20 18:44:46 UTC (rev 1340)
@@ -58,7 +58,8 @@
         std::exception(),
         _err_code(err_code)
 {
-    ::sprintf(_what_msg, "jexception 0x%04X", err_code);
+    ::sprintf(_what_msg, "jexception 0x%04X ", err_code);
+    ::strncat(_what_msg, jerrno::err_msg(err_code), CATLEN(_what_msg));
     *_additional_info = '\0';
     *_throwing_class = '\0';
     *_throwing_fn = '\0';
@@ -86,11 +87,14 @@
         _err_code(err_code)
 {
     ::sprintf(_what_msg, "jexception 0x%04X ", err_code);
+    ::strncat(_what_msg, jerrno::err_msg(err_code), CATLEN(_what_msg));
     if (additional_info)
     {
         ::strncpy(_additional_info, additional_info, MAX_MSG_SIZE - 1);
         _additional_info[MAX_MSG_SIZE - 1] = '\0';
+        ::strncat(_what_msg, " (", CATLEN(_what_msg));
         ::strncat(_what_msg, _additional_info, CATLEN(_what_msg));
+        ::strncat(_what_msg, ")", CATLEN(_what_msg));
     }
     else
         *_additional_info = '\0';
@@ -112,6 +116,8 @@
         ::strncat(_what_msg, _throwing_class, CATLEN(_what_msg));
         if (throwing_fn)
             ::strncat(_what_msg, "::", CATLEN(_what_msg));
+        else
+            ::strncat(_what_msg, " ", CATLEN(_what_msg));
     }
     else
         *_throwing_class = '\0';
@@ -120,9 +126,13 @@
         ::strncpy(_throwing_fn, throwing_fn, MAX_THROWING_SIZE - 1);
         _throwing_fn[MAX_THROWING_SIZE - 1] = '\0';
         ::strncat(_what_msg, _throwing_fn, CATLEN(_what_msg));
+        ::strncat(_what_msg, "() ", CATLEN(_what_msg));
     }
     else
         *_throwing_fn = '\0';
+    if (throwing_class || throwing_fn)
+        ::strncat(_what_msg, "threw ", CATLEN(_what_msg));
+    ::strncat(_what_msg, jerrno::err_msg(err_code), CATLEN(_what_msg));
 }
 
 jexception::jexception(const u_int32_t err_code, const char* additional_info,
@@ -138,7 +148,7 @@
         ::strncat(_what_msg, _throwing_class, CATLEN(_what_msg));
         if (throwing_fn)
             ::strncat(_what_msg, "::", CATLEN(_what_msg));
-        else if (additional_info)
+        else
             ::strncat(_what_msg, " ", CATLEN(_what_msg));
     }
     else
@@ -148,16 +158,20 @@
         ::strncpy(_throwing_fn, throwing_fn, MAX_THROWING_SIZE - 1);
         _throwing_fn[MAX_THROWING_SIZE - 1] = '\0';
         ::strncat(_what_msg, _throwing_fn, CATLEN(_what_msg));
-        if (additional_info)
-            ::strncat(_what_msg, " ", CATLEN(_what_msg));
+        ::strncat(_what_msg, "() ", CATLEN(_what_msg));
     }
     else
         *_throwing_fn = '\0';
+    if (throwing_class || throwing_fn)
+        ::strncat(_what_msg, "threw ", CATLEN(_what_msg));
+    ::strncat(_what_msg, jerrno::err_msg(err_code), CATLEN(_what_msg));
     if (additional_info)
     {
         ::strncpy(_additional_info, additional_info, MAX_MSG_SIZE - 1);
         _additional_info[MAX_MSG_SIZE - 1] = '\0';
+        ::strncat(_what_msg, " (", CATLEN(_what_msg));
         ::strncat(_what_msg, _additional_info, CATLEN(_what_msg));
+        ::strncat(_what_msg, ")", CATLEN(_what_msg));
     }
     else
         *_additional_info = '\0';

Modified: store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp	2007-11-20 13:58:23 UTC (rev 1339)
+++ store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp	2007-11-20 18:44:46 UTC (rev 1340)
@@ -33,6 +33,7 @@
 #include <boost/test/unit_test.hpp>
 #include <boost/test/unit_test_log.hpp>
 #include <iostream>
+#include <jrnl/jerrno.hpp>
 #include <jrnl/jexception.hpp>
 
 using namespace boost::unit_test;
@@ -261,15 +262,18 @@
     throw_exception(jexception((const char*)NULL), 11, 0);
 
     throw_exception(jexception(0x1234, long_msg), MAX_MSG_SIZE - 1, MAX_MSG_SIZE - 1);
-    throw_exception(jexception(0x1234, NULL), 18, 0);
+    throw_exception(jexception(0x1234, NULL), 18 + ::strlen(jerrno::err_msg(0x1234)), 0);
 
     throw_exception(jexception(0x1234, long_throwing_class, long_throwing_fn),
-            (2 * (MAX_THROWING_SIZE - 1)) + 20, MAX_THROWING_SIZE - 1, MAX_THROWING_SIZE - 1);
-    throw_exception(jexception(0x1234, long_throwing_class, NULL), MAX_THROWING_SIZE - 1 + 18,
-            MAX_THROWING_SIZE - 1, 0);
-    throw_exception(jexception(0x1234, NULL, long_throwing_fn), MAX_THROWING_SIZE - 1 + 18, 0,
+            29 + (2 * (MAX_THROWING_SIZE - 1)) + ::strlen(jerrno::err_msg(0x1234)),
+            MAX_THROWING_SIZE - 1, MAX_THROWING_SIZE - 1);
+    throw_exception(jexception(0x1234, long_throwing_class, NULL),
+            25 + MAX_THROWING_SIZE - 1 + ::strlen(jerrno::err_msg(0x1234)), MAX_THROWING_SIZE - 1,
+            0);
+    throw_exception(jexception(0x1234, NULL, long_throwing_fn),
+            27 + MAX_THROWING_SIZE - 1 + ::strlen(jerrno::err_msg(0x1234)), 0,
             MAX_THROWING_SIZE - 1);
-    throw_exception(jexception(0x1234, NULL, NULL), 18, 0, 0);
+    throw_exception(jexception(0x1234, NULL, NULL), 18 + ::strlen(jerrno::err_msg(0x1234)), 0, 0);
 
     throw_exception(jexception(0x1234, long_msg, long_throwing_class, long_throwing_fn),
             MAX_MSG_SIZE - 1, MAX_MSG_SIZE - 1, MAX_THROWING_SIZE - 1, MAX_THROWING_SIZE - 1);
@@ -280,12 +284,16 @@
     throw_exception(jexception(0x1234, long_msg, NULL, NULL), MAX_MSG_SIZE - 1, MAX_MSG_SIZE - 1, 0,
             0);
     throw_exception(jexception(0x1234, NULL, long_throwing_class, long_throwing_fn),
-            (2 * (MAX_THROWING_SIZE - 1)) + 20, 0, MAX_THROWING_SIZE - 1, MAX_THROWING_SIZE - 1);
-    throw_exception(jexception(0x1234, NULL, long_throwing_class, NULL), MAX_THROWING_SIZE - 1 + 18,
-            0, MAX_THROWING_SIZE - 1, 0);
-    throw_exception(jexception(0x1234, NULL, NULL, long_throwing_fn), MAX_THROWING_SIZE - 1 + 18, 0,
-            0, MAX_THROWING_SIZE - 1);
-    throw_exception(jexception(0x1234, NULL, NULL, NULL), 18, 0, 0, 0);
+            29 + (2 * (MAX_THROWING_SIZE - 1)) + ::strlen(jerrno::err_msg(0x1234)), 0,
+            MAX_THROWING_SIZE - 1, MAX_THROWING_SIZE - 1);
+    throw_exception(jexception(0x1234, NULL, long_throwing_class, NULL),
+            25 + MAX_THROWING_SIZE - 1 + ::strlen(jerrno::err_msg(0x1234)), 0,
+            MAX_THROWING_SIZE - 1, 0);
+    throw_exception(jexception(0x1234, NULL, NULL, long_throwing_fn),
+            27 + MAX_THROWING_SIZE - 1 + ::strlen(jerrno::err_msg(0x1234)), 0, 0,
+            MAX_THROWING_SIZE - 1);
+    throw_exception(jexception(0x1234, NULL, NULL, NULL), 18 + ::strlen(jerrno::err_msg(0x1234)),
+            0, 0, 0);
 }
 
 // Helper functions




More information about the rhmessaging-commits mailing list