Enhance exception throwing with Boost Exception library

Change-Id: I471023fc23ffaebe04d9668426b4c1b03e4962ba
Refs: #2997
diff --git a/src/security/sec-public-info.cpp b/src/security/sec-public-info.cpp
index 6d9cc4c..2226f51 100644
--- a/src/security/sec-public-info.cpp
+++ b/src/security/sec-public-info.cpp
@@ -78,7 +78,7 @@
     refreshDefaultCertificate();
 
   if (m_defaultCertificate == nullptr)
-    throw Error("No default certificate is set");
+    BOOST_THROW_EXCEPTION(Error("No default certificate is set"));
 
   return m_defaultCertificate->getName();
 }
@@ -98,7 +98,7 @@
   Name keyName = Name(identityName).append(oss.str());
 
   if (doesPublicKeyExist(keyName))
-    throw Error("Key name already exists: " + keyName.toUri());
+    BOOST_THROW_EXCEPTION(Error("Key name already exists: " + keyName.toUri()));
 
   return keyName;
 }