Merge with Bitcoin v0.6.3
[novacoin.git] / src / serialize.h
index 349a40b..ca12051 100644 (file)
@@ -1,5 +1,6 @@
 // Copyright (c) 2009-2010 Satoshi Nakamoto
 // Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2012 The PPCoin developers
 // Distributed under the MIT/X11 software license, see the accompanying
 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
 #ifndef BITCOIN_SERIALIZE_H
@@ -155,8 +156,14 @@ template<typename Stream> inline void Unserialize(Stream& s, bool& a, int, int=0
 
 
 
-
-
+#ifndef THROW_WITH_STACKTRACE
+#define THROW_WITH_STACKTRACE(exception)  \
+{                                         \
+    LogStackTrace();                      \
+    throw (exception);                    \
+}
+void LogStackTrace();
+#endif
 
 //
 // Compact size
@@ -234,7 +241,7 @@ uint64 ReadCompactSize(Stream& is)
         nSizeRet = xSize;
     }
     if (nSizeRet > (uint64)MAX_SIZE)
-        throw std::ios_base::failure("ReadCompactSize() : size too large");
+        THROW_WITH_STACKTRACE(std::ios_base::failure("ReadCompactSize() : size too large"));
     return nSizeRet;
 }
 
@@ -905,7 +912,7 @@ public:
     {
         state |= bits;
         if (state & exceptmask)
-            throw std::ios_base::failure(psz);
+            THROW_WITH_STACKTRACE(std::ios_base::failure(psz));
     }
 
     bool eof() const             { return size() == 0; }
@@ -1120,7 +1127,7 @@ public:
     {
         state |= bits;
         if (state & exceptmask)
-            throw std::ios_base::failure(psz);
+            THROW_WITH_STACKTRACE(std::ios_base::failure(psz));
     }
 
     bool fail() const            { return state & (std::ios::badbit | std::ios::failbit); }