Enhance exception throwing with Boost Exception library

Change-Id: I471023fc23ffaebe04d9668426b4c1b03e4962ba
Refs: #2997
diff --git a/src/encoding/block.cpp b/src/encoding/block.cpp
index 77be4f2..624439d 100644
--- a/src/encoding/block.cpp
+++ b/src/encoding/block.cpp
@@ -63,7 +63,7 @@
   uint64_t length = tlv::readVarNumber(m_value_begin, m_value_end);
   if (length != static_cast<uint64_t>(m_value_end - m_value_begin))
     {
-      throw tlv::Error("TLV length doesn't match buffer length");
+      BOOST_THROW_EXCEPTION(tlv::Error("TLV length doesn't match buffer length"));
     }
 }
 
@@ -95,7 +95,7 @@
   uint64_t length = tlv::readVarNumber(m_value_begin, m_value_end);
   if (length != static_cast<uint64_t>(m_value_end - m_value_begin))
     {
-      throw tlv::Error("TLV length doesn't match buffer length");
+      BOOST_THROW_EXCEPTION(tlv::Error("TLV length doesn't match buffer length"));
     }
 }
 
@@ -116,7 +116,7 @@
     {
       if (length != static_cast<uint64_t>(m_value_end - m_value_begin))
         {
-          throw tlv::Error("TLV length doesn't match buffer length");
+          BOOST_THROW_EXCEPTION(tlv::Error("TLV length doesn't match buffer length"));
         }
     }
 }
@@ -131,7 +131,7 @@
 
   if (length > static_cast<uint64_t>(tmp_end - tmp_begin))
     {
-      throw tlv::Error("Not enough data in the buffer to fully parse TLV");
+      BOOST_THROW_EXCEPTION(tlv::Error("Not enough data in the buffer to fully parse TLV"));
     }
 
   m_buffer = make_shared<Buffer>(buffer, (tmp_begin - buffer) + length);
@@ -156,7 +156,7 @@
 
   if (length > static_cast<uint64_t>(tmp_end - tmp_begin))
     {
-      throw tlv::Error("Not enough data in the buffer to fully parse TLV");
+      BOOST_THROW_EXCEPTION(tlv::Error("Not enough data in the buffer to fully parse TLV"));
     }
 
   m_buffer = make_shared<Buffer>(buffer, (tmp_begin - buffer) + length);
@@ -210,7 +210,7 @@
   }
 
   if (length > MAX_SIZE_OF_BLOCK_FROM_STREAM)
-    throw tlv::Error("Length of block from stream is too large");
+    BOOST_THROW_EXCEPTION(tlv::Error("Length of block from stream is too large"));
 
   // We may still have some problem here, if some exception happens,
   // we may completely lose all the bytes extracted from the stream.
@@ -220,7 +220,7 @@
   is.read(buf + 1, length - 1);
 
   if (length != static_cast<uint64_t>(is.gcount()) + 1) {
-    throw tlv::Error("Not enough data in the buffer to fully parse TLV");
+    BOOST_THROW_EXCEPTION(tlv::Error("Not enough data in the buffer to fully parse TLV"));
   }
 
   return makeBinaryBlock(type, buf, length);
@@ -314,7 +314,7 @@
       if (length > static_cast<uint64_t>(end - begin))
         {
           m_subBlocks.clear();
-          throw tlv::Error("TLV length exceeds buffer length");
+          BOOST_THROW_EXCEPTION(tlv::Error("TLV length exceeds buffer length"));
         }
       Buffer::const_iterator element_end = begin + length;
 
@@ -364,7 +364,7 @@
           os.write(reinterpret_cast<const char*>(i->value()), i->value_size());
         }
         else
-          throw Error("Underlying value buffer is empty");
+          BOOST_THROW_EXCEPTION(Error("Underlying value buffer is empty"));
       }
     }
 
@@ -389,8 +389,8 @@
   if (it != m_subBlocks.end())
     return *it;
 
-  throw Error("(Block::get) Requested a non-existed type [" +
-              boost::lexical_cast<std::string>(type) + "] from Block");
+  BOOST_THROW_EXCEPTION(Error("(Block::get) Requested a non-existed type [" +
+                              boost::lexical_cast<std::string>(type) + "] from Block"));
 }
 
 Block::element_const_iterator
@@ -414,7 +414,7 @@
 Block::blockFromValue() const
 {
   if (value_size() == 0)
-    throw Error("Underlying value buffer is empty");
+    BOOST_THROW_EXCEPTION(Error("Underlying value buffer is empty"));
 
   Buffer::const_iterator begin = value_begin(),
                          end = value_end();
@@ -425,7 +425,7 @@
   uint64_t length = tlv::readVarNumber(begin, end);
 
   if (length != static_cast<uint64_t>(end - begin))
-    throw tlv::Error("TLV length mismatches buffer length");
+    BOOST_THROW_EXCEPTION(tlv::Error("TLV length mismatches buffer length"));
 
   return Block(m_buffer,
                type,
@@ -454,7 +454,7 @@
 Block::begin() const
 {
   if (!hasWire())
-    throw Error("Underlying wire buffer is empty");
+    BOOST_THROW_EXCEPTION(Error("Underlying wire buffer is empty"));
 
   return m_begin;
 }
@@ -463,7 +463,7 @@
 Block::end() const
 {
   if (!hasWire())
-    throw Error("Underlying wire buffer is empty");
+    BOOST_THROW_EXCEPTION(Error("Underlying wire buffer is empty"));
 
   return m_end;
 }
@@ -472,7 +472,7 @@
 Block::wire() const
 {
   if (!hasWire())
-    throw Error("(Block::wire) Underlying wire buffer is empty");
+    BOOST_THROW_EXCEPTION(Error("(Block::wire) Underlying wire buffer is empty"));
 
   return &*m_begin;
 }
@@ -484,7 +484,7 @@
     return m_size;
   }
   else
-    throw Error("Block size cannot be determined (undefined block size)");
+    BOOST_THROW_EXCEPTION(Error("Block size cannot be determined (undefined block size)"));
 }
 
 bool