Enhance exception throwing with Boost Exception library

Change-Id: I471023fc23ffaebe04d9668426b4c1b03e4962ba
Refs: #2997
diff --git a/src/security/sec-public-info-sqlite3.cpp b/src/security/sec-public-info-sqlite3.cpp
index 65e394c..462f215 100644
--- a/src/security/sec-public-info-sqlite3.cpp
+++ b/src/security/sec-public-info-sqlite3.cpp
@@ -130,7 +130,7 @@
 #endif
                             );
   if (res != SQLITE_OK)
-    throw Error("identity DB cannot be opened/created");
+    BOOST_THROW_EXCEPTION(Error("identity DB cannot be opened/created"));
 
 
   BOOST_ASSERT(m_database != nullptr);
@@ -228,7 +228,7 @@
   }
   else {
     sqlite3_finalize(statement);
-    throw SecPublicInfo::Error("TPM info does not exist");
+    BOOST_THROW_EXCEPTION(SecPublicInfo::Error("TPM info does not exist"));
   }
 }
 
@@ -321,7 +321,7 @@
 SecPublicInfoSqlite3::doesPublicKeyExist(const Name& keyName)
 {
   if (keyName.empty())
-    throw Error("Incorrect key name " + keyName.toUri());
+    BOOST_THROW_EXCEPTION(Error("Incorrect key name " + keyName.toUri()));
 
   string keyId = keyName.get(-1).toUri();
   Name identityName = keyName.getPrefix(-1);
@@ -387,7 +387,7 @@
 SecPublicInfoSqlite3::getPublicKey(const Name& keyName)
 {
   if (keyName.empty())
-    throw Error("SecPublicInfoSqlite3::getPublicKey  Empty keyName");
+    BOOST_THROW_EXCEPTION(Error("SecPublicInfoSqlite3::getPublicKey  Empty keyName"));
 
   string keyId = keyName.get(-1).toUri();
   Name identityName = keyName.getPrefix(-1);
@@ -411,7 +411,7 @@
   }
   else {
     sqlite3_finalize(statement);
-    throw Error("SecPublicInfoSqlite3::getPublicKey  public key does not exist");
+    BOOST_THROW_EXCEPTION(Error("SecPublicInfoSqlite3::getPublicKey  public key does not exist"));
   }
 }
 
@@ -545,7 +545,8 @@
     }
     catch (tlv::Error&) {
       sqlite3_finalize(statement);
-      throw Error("SecPublicInfoSqlite3::getCertificate  certificate cannot be decoded");
+      BOOST_THROW_EXCEPTION(Error("SecPublicInfoSqlite3::getCertificate  certificate cannot be "
+                                  "decoded"));
     }
 
     sqlite3_finalize(statement);
@@ -553,7 +554,8 @@
   }
   else {
     sqlite3_finalize(statement);
-    throw Error("SecPublicInfoSqlite3::getCertificate  certificate does not exist");
+    BOOST_THROW_EXCEPTION(Error("SecPublicInfoSqlite3::getCertificate  certificate does not "
+                                "exist"));
   }
 }
 
@@ -575,7 +577,7 @@
   }
   else {
     sqlite3_finalize(statement);
-    throw Error("SecPublicInfoSqlite3::getDefaultIdentity  no default identity");
+    BOOST_THROW_EXCEPTION(Error("SecPublicInfoSqlite3::getDefaultIdentity  no default identity"));
   }
 }
 
@@ -629,7 +631,8 @@
   }
   else {
     sqlite3_finalize(statement);
-    throw Error("SecPublicInfoSqlite3::getDefaultKeyNameForIdentity key not found");
+    BOOST_THROW_EXCEPTION(Error("SecPublicInfoSqlite3::getDefaultKeyNameForIdentity key not "
+                                "found"));
   }
 }
 
@@ -637,7 +640,7 @@
 SecPublicInfoSqlite3::setDefaultKeyNameForIdentityInternal(const Name& keyName)
 {
   if (!doesPublicKeyExist(keyName))
-    throw Error("Key does not exist:" + keyName.toUri());
+    BOOST_THROW_EXCEPTION(Error("Key does not exist:" + keyName.toUri()));
 
   string keyId = keyName.get(-1).toUri();
   Name identityName = keyName.getPrefix(-1);
@@ -673,7 +676,7 @@
 SecPublicInfoSqlite3::getDefaultCertificateNameForKey(const Name& keyName)
 {
   if (keyName.empty())
-    throw Error("SecPublicInfoSqlite3::getDefaultCertificateNameForKey wrong key");
+    BOOST_THROW_EXCEPTION(Error("SecPublicInfoSqlite3::getDefaultCertificateNameForKey wrong key"));
 
   string keyId = keyName.get(-1).toUri();
   Name identityName = keyName.getPrefix(-1);
@@ -697,7 +700,7 @@
   }
   else {
     sqlite3_finalize(statement);
-    throw Error("certificate not found");
+    BOOST_THROW_EXCEPTION(Error("certificate not found"));
   }
 }
 
@@ -705,7 +708,7 @@
 SecPublicInfoSqlite3::setDefaultCertificateNameForKeyInternal(const Name& certificateName)
 {
   if (!doesCertificateExist(certificateName))
-    throw Error("certificate does not exist:" + certificateName.toUri());
+    BOOST_THROW_EXCEPTION(Error("certificate does not exist:" + certificateName.toUri()));
 
   Name keyName = IdentityCertificate::certificateNameToPublicKeyName(certificateName);
   string keyId = keyName.get(-1).toUri();