Enhance exception throwing with Boost Exception library

Change-Id: I471023fc23ffaebe04d9668426b4c1b03e4962ba
Refs: #2997
diff --git a/src/security/identity.cpp b/src/security/identity.cpp
index 128b7bc..1093b9f 100644
--- a/src/security/identity.cpp
+++ b/src/security/identity.cpp
@@ -46,7 +46,7 @@
   if (needInit)
     m_impl->addIdentity(m_name);
   else if (!m_impl->hasIdentity(m_name))
-    throw Pib::Error("Identity: " + m_name.toUri() + " does not exist");
+    BOOST_THROW_EXCEPTION(Pib::Error("Identity: " + m_name.toUri() + " does not exist"));
 }
 
 const Name&
@@ -157,7 +157,7 @@
 Identity::validityCheck() const
 {
   if (m_impl == nullptr)
-    throw std::domain_error("Invalid Identity instance");
+    BOOST_THROW_EXCEPTION(std::domain_error("Invalid Identity instance"));
 }
 
 } // namespace security