Date: Tuesday, December 5, 2006 @ 01:40:13
  Author: marc
    Path: /cvsroot/carob/carob/test

Modified: CarobProtector.hpp (1.17 -> 1.18)

Implemented pretty-printer operator<< for whole CarobException


--------------------+
 CarobProtector.hpp |   52 ++++++++++++++++++---------------------------------
 1 files changed, 19 insertions(+), 33 deletions(-)


Index: carob/test/CarobProtector.hpp
diff -u carob/test/CarobProtector.hpp:1.17 carob/test/CarobProtector.hpp:1.18
--- carob/test/CarobProtector.hpp:1.17  Tue Dec  5 01:13:16 2006
+++ carob/test/CarobProtector.hpp       Tue Dec  5 01:40:13 2006
@@ -33,47 +33,33 @@
 static const std::wstring NEXTPREFIX(L"chained CarobException : ");
 
 
-static void cerrStackTrace(std::wostream& outstream, const std::wstring& 
prefix,
-    const CarobNS::CarobException& cex)
-{
-  outstream << prefix;
-  outstream << " SQL state: " << cex.getSQLState() << ", remote stack: " << 
std::endl;
-  outstream <<  cex.getStackTrace();
-}
-
-
-static void cerrBackTrace(std::wostream& outstream, const std::wstring& prefix,
-    const CarobNS::CarobException& cex)
-{
-    outstream << prefix << std::endl;
-    outstream << cex.getBackTrace();
-}
 
-
-static std::wstring carobExceptionChain(const std::wstring& prefix,
-    const CarobNS::CarobException& ce)
+std::wostream& operator<<(std::wostream& woss, const CarobNS::CarobException& 
ce)
 {
-  std::wostringstream woss;
-
-  cerrBackTrace(woss, prefix, ce);
-  cerrStackTrace(woss, prefix, ce);
-
-  const CarobNS::CarobException* nextex_p = &ce;
-  
-  while ((nextex_p = nextex_p->getNext()) != NULL) {
-    woss << "   ---  chained CarobException  --- " << std::endl;
-    cerrBackTrace(woss, NEXTPREFIX, *nextex_p);
-    cerrStackTrace(woss, NEXTPREFIX, *nextex_p);
-  } 
-
-  return woss.str();
+    woss << " SQL state: " << ce.getSQLState() << std::endl;
+    woss << ce.getBackTrace();
+    woss << "      -- remote stack -- " << std::endl;
+    woss <<  ce.getStackTrace();
+
+    const CarobNS::CarobException* nextex_p = ce.getNext();
+    
+    if (nextex_p != NULL) {
+        woss << "   ---  chained CarobException  --- ";
+        woss << *nextex_p;
+  }
 
+  return woss;
 }
 
 static void cerrCarobExceptionChain(const std::wstring& prefix,
     const CarobNS::CarobException& ce)
 {
-    CarobNS::logError(L"cerrCarobExceptionChain", carobExceptionChain(prefix, 
ce));
+    std::wostringstream woss;
+
+    woss << prefix;
+    woss << ce;
+
+    CarobNS::logError(L"cerrCarobExceptionChain", woss.str());
 }
 
 

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to