diff --git a/src/security/conf/checker.hpp b/src/security/conf/checker.hpp
index 1364229..bb651bc 100644
--- a/src/security/conf/checker.hpp
+++ b/src/security/conf/checker.hpp
@@ -104,14 +104,14 @@
       case tlv::SignatureSha256WithEcdsa:
         {
           if (!static_cast<bool>(m_keyLocatorChecker))
-            throw Error("Strong signature requires KeyLocatorChecker");
+            BOOST_THROW_EXCEPTION(Error("Strong signature requires KeyLocatorChecker"));
 
           return;
         }
       case tlv::DigestSha256:
         return;
       default:
-        throw Error("Unsupported signature type");
+        BOOST_THROW_EXCEPTION(Error("Unsupported signature type"));
       }
   }
 
@@ -245,7 +245,7 @@
     if (sigType != tlv::SignatureSha256WithRsa &&
         sigType != tlv::SignatureSha256WithEcdsa)
       {
-        throw Error("FixedSigner is only meaningful for strong signature type");
+        BOOST_THROW_EXCEPTION(Error("FixedSigner is only meaningful for strong signature type"));
       }
 
   }
@@ -389,7 +389,7 @@
 
     // Get checker.type
     if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "type"))
-      throw Error("Expect <checker.type>");
+      BOOST_THROW_EXCEPTION(Error("Expect <checker.type>"));
 
     std::string type = propertyIt->second.data();
 
@@ -400,7 +400,7 @@
     else if (boost::iequals(type, "fixed-signer"))
       return createFixedSignerChecker(configSection, configFilename);
     else
-      throw Error("Unsupported checker type: " + type);
+      BOOST_THROW_EXCEPTION(Error("Unsupported checker type: " + type));
   }
 
 private:
@@ -413,21 +413,21 @@
 
     // Get checker.sig-type
     if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "sig-type"))
-      throw Error("Expect <checker.sig-type>");
+      BOOST_THROW_EXCEPTION(Error("Expect <checker.sig-type>"));
 
     std::string sigType = propertyIt->second.data();
     propertyIt++;
 
     // Get checker.key-locator
     if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "key-locator"))
-      throw Error("Expect <checker.key-locator>");
+      BOOST_THROW_EXCEPTION(Error("Expect <checker.key-locator>"));
 
     shared_ptr<KeyLocatorChecker> keyLocatorChecker =
       KeyLocatorCheckerFactory::create(propertyIt->second, configFilename);
     propertyIt++;
 
     if (propertyIt != configSection.end())
-      throw Error("Expect the end of checker");
+      BOOST_THROW_EXCEPTION(Error("Expect the end of checker"));
 
     return make_shared<CustomizedChecker>(getSigType(sigType), keyLocatorChecker);
   }
@@ -441,13 +441,13 @@
 
     // Get checker.sig-type
     if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "sig-type"))
-      throw Error("Expect <checker.sig-type>");
+      BOOST_THROW_EXCEPTION(Error("Expect <checker.sig-type>"));
 
     std::string sigType = propertyIt->second.data();
     propertyIt++;
 
     if (propertyIt != configSection.end())
-      throw Error("Expect the end of checker");
+      BOOST_THROW_EXCEPTION(Error("Expect the end of checker"));
 
     return make_shared<HierarchicalChecker>(getSigType(sigType));
   }
@@ -461,7 +461,7 @@
 
     // Get checker.sig-type
     if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "sig-type"))
-      throw Error("Expect <checker.sig-type>");
+      BOOST_THROW_EXCEPTION(Error("Expect <checker.sig-type>"));
 
     std::string sigType = propertyIt->second.data();
     propertyIt++;
@@ -470,14 +470,14 @@
     for (; propertyIt != configSection.end(); propertyIt++)
       {
         if (!boost::iequals(propertyIt->first, "signer"))
-          throw Error("Expect <checker.signer> but get <checker." +
-                      propertyIt->first + ">");
+          BOOST_THROW_EXCEPTION(Error("Expect <checker.signer> but get <checker." +
+                                      propertyIt->first + ">"));
 
         signers.push_back(getSigner(propertyIt->second, configFilename));
       }
 
     if (propertyIt != configSection.end())
-      throw Error("Expect the end of checker");
+      BOOST_THROW_EXCEPTION(Error("Expect the end of checker"));
 
     return shared_ptr<FixedSignerChecker>(new FixedSignerChecker(getSigType(sigType),
                                                                  signers));
@@ -492,7 +492,7 @@
 
     // Get checker.signer.type
     if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "type"))
-      throw Error("Expect <checker.signer.type>");
+      BOOST_THROW_EXCEPTION(Error("Expect <checker.signer.type>"));
 
     std::string type = propertyIt->second.data();
     propertyIt++;
@@ -501,14 +501,14 @@
       {
         // Get checker.signer.file-name
         if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "file-name"))
-          throw Error("Expect <checker.signer.file-name>");
+          BOOST_THROW_EXCEPTION(Error("Expect <checker.signer.file-name>"));
 
         path certfilePath = absolute(propertyIt->second.data(),
                                      path(configFilename).parent_path());
         propertyIt++;
 
         if (propertyIt != configSection.end())
-          throw Error("Expect the end of checker.signer");
+          BOOST_THROW_EXCEPTION(Error("Expect the end of checker.signer"));
 
         shared_ptr<IdentityCertificate> idCert
           = io::load<IdentityCertificate>(certfilePath.c_str());
@@ -516,31 +516,31 @@
         if (static_cast<bool>(idCert))
           return idCert;
         else
-          throw Error("Cannot read certificate from file: " +
-                      certfilePath.native());
+          BOOST_THROW_EXCEPTION(Error("Cannot read certificate from file: " +
+                                      certfilePath.native()));
       }
     else if (boost::iequals(type, "base64"))
       {
         // Get checker.signer.base64-string
         if (propertyIt == configSection.end() ||
             !boost::iequals(propertyIt->first, "base64-string"))
-          throw Error("Expect <checker.signer.base64-string>");
+          BOOST_THROW_EXCEPTION(Error("Expect <checker.signer.base64-string>"));
 
         std::stringstream ss(propertyIt->second.data());
         propertyIt++;
 
         if (propertyIt != configSection.end())
-          throw Error("Expect the end of checker.signer");
+          BOOST_THROW_EXCEPTION(Error("Expect the end of checker.signer"));
 
         shared_ptr<IdentityCertificate> idCert = io::load<IdentityCertificate>(ss);
 
         if (static_cast<bool>(idCert))
           return idCert;
         else
-          throw Error("Cannot decode certificate from string");
+          BOOST_THROW_EXCEPTION(Error("Cannot decode certificate from string"));
       }
     else
-      throw Error("Unsupported checker.signer type: " + type);
+      BOOST_THROW_EXCEPTION(Error("Unsupported checker.signer type: " + type));
   }
 
   static uint32_t
@@ -553,7 +553,7 @@
     else if (boost::iequals(sigType, "sha256"))
       return tlv::DigestSha256;
     else
-      throw Error("Unsupported signature type");
+      BOOST_THROW_EXCEPTION(Error("Unsupported signature type"));
   }
 };
 
diff --git a/src/security/conf/filter.hpp b/src/security/conf/filter.hpp
index 8d0601c..3dfddde 100644
--- a/src/security/conf/filter.hpp
+++ b/src/security/conf/filter.hpp
@@ -152,14 +152,14 @@
     ConfigSection::const_iterator propertyIt = configSection.begin();
 
     if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "type"))
-      throw Error("Expect <filter.type>!");
+      BOOST_THROW_EXCEPTION(Error("Expect <filter.type>!"));
 
     std::string type = propertyIt->second.data();
 
     if (boost::iequals(type, "name"))
       return createNameFilter(configSection);
     else
-      throw Error("Unsupported filter.type: " + type);
+      BOOST_THROW_EXCEPTION(Error("Unsupported filter.type: " + type));
   }
 private:
   static shared_ptr<Filter>
@@ -169,7 +169,7 @@
     propertyIt++;
 
     if (propertyIt == configSection.end())
-      throw Error("Expect more properties for filter(name)");
+      BOOST_THROW_EXCEPTION(Error("Expect more properties for filter(name)"));
 
     if (boost::iequals(propertyIt->first, "name"))
       {
@@ -181,14 +181,14 @@
           }
         catch (Name::Error& e)
           {
-            throw Error("Wrong filter.name: " + propertyIt->second.data());
+            BOOST_THROW_EXCEPTION(Error("Wrong filter.name: " + propertyIt->second.data()));
           }
 
         propertyIt++;
 
         // Get filter.relation
         if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "relation"))
-          throw Error("Expect <filter.relation>!");
+          BOOST_THROW_EXCEPTION(Error("Expect <filter.relation>!"));
 
         std::string relationString = propertyIt->second.data();
         propertyIt++;
@@ -201,11 +201,11 @@
         else if (boost::iequals(relationString, "is-strict-prefix-of"))
           relation = RelationNameFilter::RELATION_IS_STRICT_PREFIX_OF;
         else
-          throw Error("Unsupported relation: " + relationString);
+          BOOST_THROW_EXCEPTION(Error("Unsupported relation: " + relationString));
 
 
         if (propertyIt != configSection.end())
-          throw Error("Expect the end of filter!");
+          BOOST_THROW_EXCEPTION(Error("Expect the end of filter!"));
 
         return make_shared<RelationNameFilter>(name, relation);
       }
@@ -215,7 +215,7 @@
         propertyIt++;
 
         if (propertyIt != configSection.end())
-          throw Error("Expect the end of filter!");
+          BOOST_THROW_EXCEPTION(Error("Expect the end of filter!"));
 
         try
           {
@@ -223,11 +223,11 @@
           }
         catch (Regex::Error& e)
           {
-            throw Error("Wrong filter.regex: " + regexString);
+            BOOST_THROW_EXCEPTION(Error("Wrong filter.regex: " + regexString));
           }
       }
     else
-      throw Error("Wrong filter(name) properties");
+      BOOST_THROW_EXCEPTION(Error("Wrong filter(name) properties"));
   }
 };
 
diff --git a/src/security/conf/key-locator-checker.hpp b/src/security/conf/key-locator-checker.hpp
index 7d5bb9c..667dfeb 100644
--- a/src/security/conf/key-locator-checker.hpp
+++ b/src/security/conf/key-locator-checker.hpp
@@ -234,14 +234,14 @@
 
     // Get checker.key-locator.type
     if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "type"))
-      throw Error("Expect <checker.key-locator.type>!");
+      BOOST_THROW_EXCEPTION(Error("Expect <checker.key-locator.type>!"));
 
     std::string type = propertyIt->second.data();
 
     if (boost::iequals(type, "name"))
       return createKeyLocatorNameChecker(configSection, filename);
     else
-      throw Error("Unsupported checker.key-locator.type: " + type);
+      BOOST_THROW_EXCEPTION(Error("Unsupported checker.key-locator.type: " + type));
   }
 
 private:
@@ -253,7 +253,7 @@
     propertyIt++;
 
     if (propertyIt == configSection.end())
-      throw Error("Expect more checker.key-locator properties");
+      BOOST_THROW_EXCEPTION(Error("Expect more checker.key-locator properties"));
 
     if (boost::iequals(propertyIt->first, "name"))
       {
@@ -264,13 +264,13 @@
           }
         catch (Name::Error& e)
           {
-            throw Error("Invalid checker.key-locator.name: " +
-                        propertyIt->second.data());
+            BOOST_THROW_EXCEPTION(Error("Invalid checker.key-locator.name: " +
+                                        propertyIt->second.data()));
           }
         propertyIt++;
 
         if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first, "relation"))
-          throw Error("Expect <checker.key-locator.relation>!");
+          BOOST_THROW_EXCEPTION(Error("Expect <checker.key-locator.relation>!"));
 
         std::string relationString = propertyIt->second.data();
         propertyIt++;
@@ -283,10 +283,10 @@
         else if (boost::iequals(relationString, "is-strict-prefix-of"))
           relation = KeyLocatorChecker::RELATION_IS_STRICT_PREFIX_OF;
         else
-          throw Error("Unsupported relation: " + relationString);
+          BOOST_THROW_EXCEPTION(Error("Unsupported relation: " + relationString));
 
         if (propertyIt != configSection.end())
-          throw Error("Expect the end of checker.key-locator!");
+          BOOST_THROW_EXCEPTION(Error("Expect the end of checker.key-locator!"));
 
         return shared_ptr<RelationKeyLocatorNameChecker>
           (new RelationKeyLocatorNameChecker(name, relation));
@@ -297,7 +297,7 @@
         propertyIt++;
 
         if (propertyIt != configSection.end())
-          throw Error("Expect the end of checker.key-locator!");
+          BOOST_THROW_EXCEPTION(Error("Expect the end of checker.key-locator!"));
 
         try
           {
@@ -306,7 +306,7 @@
           }
         catch (Regex::Error& e)
           {
-            throw Error("Invalid checker.key-locator.regex: " + regexString);
+            BOOST_THROW_EXCEPTION(Error("Invalid checker.key-locator.regex: " + regexString));
           }
       }
     else if (boost::iequals(propertyIt->first, "hyper-relation"))
@@ -317,41 +317,41 @@
 
         // Get k-regex
         if (hPropertyIt == hSection.end() || !boost::iequals(hPropertyIt->first, "k-regex"))
-          throw Error("Expect <checker.key-locator.hyper-relation.k-regex>!");
+          BOOST_THROW_EXCEPTION(Error("Expect <checker.key-locator.hyper-relation.k-regex>!"));
 
         std::string kRegex = hPropertyIt->second.data();
         hPropertyIt++;
 
         // Get k-expand
         if (hPropertyIt == hSection.end() || !boost::iequals(hPropertyIt->first, "k-expand"))
-          throw Error("Expect <checker.key-locator.hyper-relation.k-expand>!");
+          BOOST_THROW_EXCEPTION(Error("Expect <checker.key-locator.hyper-relation.k-expand>!"));
 
         std::string kExpand = hPropertyIt->second.data();
         hPropertyIt++;
 
         // Get h-relation
         if (hPropertyIt == hSection.end() || !boost::iequals(hPropertyIt->first, "h-relation"))
-          throw Error("Expect <checker.key-locator.hyper-relation.h-relation>!");
+          BOOST_THROW_EXCEPTION(Error("Expect <checker.key-locator.hyper-relation.h-relation>!"));
 
         std::string hRelation = hPropertyIt->second.data();
         hPropertyIt++;
 
         // Get p-regex
         if (hPropertyIt == hSection.end() || !boost::iequals(hPropertyIt->first, "p-regex"))
-          throw Error("Expect <checker.key-locator.hyper-relation.p-regex>!");
+          BOOST_THROW_EXCEPTION(Error("Expect <checker.key-locator.hyper-relation.p-regex>!"));
 
         std::string pRegex = hPropertyIt->second.data();
         hPropertyIt++;
 
         // Get p-expand
         if (hPropertyIt == hSection.end() || !boost::iequals(hPropertyIt->first, "p-expand"))
-          throw Error("Expect <checker.key-locator.hyper-relation.p-expand>!");
+          BOOST_THROW_EXCEPTION(Error("Expect <checker.key-locator.hyper-relation.p-expand>!"));
 
         std::string pExpand = hPropertyIt->second.data();
         hPropertyIt++;
 
         if (hPropertyIt != hSection.end())
-          throw Error("Expect the end of checker.key-locator.hyper-relation!");
+          BOOST_THROW_EXCEPTION(Error("Expect the end of checker.key-locator.hyper-relation!"));
 
         KeyLocatorChecker::Relation relation;
         if (boost::iequals(hRelation, "equal"))
@@ -361,7 +361,8 @@
         else if (boost::iequals(hRelation, "is-strict-prefix-of"))
           relation = KeyLocatorChecker::RELATION_IS_STRICT_PREFIX_OF;
         else
-          throw Error("Unsupported checker.key-locator.hyper-relation.h-relation: " + hRelation);
+          BOOST_THROW_EXCEPTION(Error("Unsupported checker.key-locator.hyper-relation.h-relation: "
+                                      + hRelation));
 
         try
           {
@@ -372,11 +373,11 @@
           }
         catch (Regex::Error& e)
           {
-            throw Error("Invalid regex for key-locator.hyper-relation");
+            BOOST_THROW_EXCEPTION(Error("Invalid regex for key-locator.hyper-relation"));
           }
       }
     else
-      throw Error("Unsupported checker.key-locator");
+      BOOST_THROW_EXCEPTION(Error("Unsupported checker.key-locator"));
   }
 };
 
