diff --git a/src/security/sec-tpm-osx.cpp b/src/security/sec-tpm-osx.cpp
index 4400343..33a2c7f 100644
--- a/src/security/sec-tpm-osx.cpp
+++ b/src/security/sec-tpm-osx.cpp
@@ -250,7 +250,7 @@
   OSStatus res = SecKeychainCopyDefault(&m_impl->m_keyChainRef);
 
   if (res == errSecNoDefaultKeychain) //If no default key chain, create one.
-    throw Error("No default keychain, create one first!");
+    BOOST_THROW_EXCEPTION(Error("No default keychain, please create one first"));
 }
 
 SecTpmOsx::~SecTpmOsx()
@@ -377,7 +377,7 @@
 
   if (doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC))
     {
-      throw Error("keyName has existed");
+      BOOST_THROW_EXCEPTION(Error("keyName already exists"));
     }
 
   string keyNameUri = m_impl->toInternalKeyName(keyName, KEY_CLASS_PUBLIC);
@@ -410,7 +410,7 @@
         break;
       }
     default:
-      throw Error("Fail to create a key pair: Unsupported key type");
+      BOOST_THROW_EXCEPTION(Error("Fail to create a key pair: Unsupported key type"));
     }
 
   CFReleaser<CFNumberRef> cfKeySize = CFNumberCreate(0, kCFNumberIntType, &keySize);
@@ -434,11 +434,11 @@
       if (unlockTpm(0, 0, false))
         generateKeyPairInTpmInternal(keyName, params, true);
       else
-        throw Error("Fail to unlock the keychain");
+        BOOST_THROW_EXCEPTION(Error("Fail to unlock the keychain"));
     }
   else
     {
-      throw Error("Fail to create a key pair");
+      BOOST_THROW_EXCEPTION(Error("Fail to create a key pair"));
     }
 }
 
@@ -473,7 +473,7 @@
 void
 SecTpmOsx::generateSymmetricKeyInTpm(const Name& keyName, const KeyParams& params)
 {
-  throw Error("SecTpmOsx::generateSymmetricKeyInTpm is not supported");
+  BOOST_THROW_EXCEPTION(Error("SecTpmOsx::generateSymmetricKeyInTpm is not supported"));
   // if (doesKeyExistInTpm(keyName, KEY_CLASS_SYMMETRIC))
   //   throw Error("keyName has existed!");
 
@@ -511,7 +511,8 @@
   CFReleaser<SecKeychainItemRef> publicKey = m_impl->getKey(keyName, KEY_CLASS_PUBLIC);
   if (publicKey.get() == 0)
     {
-      throw Error("Requested public key [" + keyName.toUri() + "] does not exist in OSX Keychain");
+      BOOST_THROW_EXCEPTION(Error("Requested public key [" + keyName.toUri() + "] does not exist "
+                                  "in OSX Keychain"));
     }
 
   CFReleaser<CFDataRef> exportedKey;
@@ -522,7 +523,7 @@
                                &exportedKey.get());
   if (res != errSecSuccess)
     {
-      throw Error("Cannot export requested public key from OSX Keychain");
+      BOOST_THROW_EXCEPTION(Error("Cannot export requested public key from OSX Keychain"));
     }
 
   shared_ptr<PublicKey> key = make_shared<PublicKey>(CFDataGetBytePtr(exportedKey.get()),
@@ -545,7 +546,8 @@
   if (privateKey.get() == 0)
     {
       /// @todo Can this happen because of keychain is locked?
-      throw Error("Private key [" + keyName.toUri() + "] does not exist in OSX Keychain");
+      BOOST_THROW_EXCEPTION(Error("Private key [" + keyName.toUri() + "] does not exist "
+                                  "in OSX Keychain"));
     }
 
   shared_ptr<PublicKey> publicKey = getPublicKeyFromTpm(keyName);
@@ -597,8 +599,8 @@
       break;
     }
   default:
-    throw Error("Unsupported key type" +
-                boost::lexical_cast<std::string>(publicKey->getKeyType()));
+    BOOST_THROW_EXCEPTION(Error("Unsupported key type" +
+                                boost::lexical_cast<std::string>(publicKey->getKeyType())));
   }
 
   OBufferStream pkcs8Os;
@@ -813,7 +815,8 @@
   CFReleaser<SecKeychainItemRef> privateKey = m_impl->getKey(keyName, KEY_CLASS_PRIVATE);
   if (privateKey.get() == 0)
     {
-      throw Error("Private key [" + keyName.toUri() + "] does not exist in OSX Keychain");
+      BOOST_THROW_EXCEPTION(Error("Private key [" + keyName.toUri() + "] does not exist "
+                                  "in OSX Keychain"));
     }
 
   CFReleaser<CFErrorRef> error;
@@ -821,7 +824,7 @@
   CFReleaser<SecTransformRef> signer = SecSignTransformCreate((SecKeyRef)privateKey.get(),
                                                               &error.get());
   if (error.get() != 0)
-    throw Error("Fail to create signer");
+    BOOST_THROW_EXCEPTION(Error("Fail to create signer"));
 
   // Set input
   SecTransformSetAttribute(signer.get(),
@@ -829,7 +832,7 @@
                            dataRef.get(),
                            &error.get());
   if (error.get() != 0)
-    throw Error("Fail to configure input of signer");
+    BOOST_THROW_EXCEPTION(Error("Fail to configure input of signer"));
 
   // Enable use of padding
   SecTransformSetAttribute(signer.get(),
@@ -837,7 +840,7 @@
                            kSecPaddingPKCS1Key,
                            &error.get());
   if (error.get() != 0)
-    throw Error("Fail to configure digest algorithm of signer");
+    BOOST_THROW_EXCEPTION(Error("Fail to configure digest algorithm of signer"));
 
   // Set padding type
   SecTransformSetAttribute(signer.get(),
@@ -845,7 +848,7 @@
                            m_impl->getDigestAlgorithm(digestAlgorithm),
                            &error.get());
   if (error.get() != 0)
-    throw Error("Fail to configure digest algorithm of signer");
+    BOOST_THROW_EXCEPTION(Error("Fail to configure digest algorithm of signer"));
 
   // Set padding attribute
   long digestSize = m_impl->getDigestSize(digestAlgorithm);
@@ -855,7 +858,7 @@
                            cfDigestSize.get(),
                            &error.get());
   if (error.get() != 0)
-    throw Error("Fail to configure digest size of signer");
+    BOOST_THROW_EXCEPTION(Error("Fail to configure digest size of signer"));
 
   // Actually sign
   // C-style cast is used as per Apple convention
@@ -867,17 +870,17 @@
           if (unlockTpm(0, 0, false))
             return signInTpmInternal(data, dataLength, keyName, digestAlgorithm, true);
           else
-            throw Error("Fail to unlock the keychain");
+            BOOST_THROW_EXCEPTION(Error("Fail to unlock the keychain"));
         }
       else
         {
           CFShow(error.get());
-          throw Error("Fail to sign data");
+          BOOST_THROW_EXCEPTION(Error("Fail to sign data"));
         }
     }
 
   if (signature.get() == 0)
-    throw Error("Signature is NULL!\n");
+    BOOST_THROW_EXCEPTION(Error("Signature is NULL!\n"));
 
   return Block(tlv::SignatureValue,
                make_shared<Buffer>(CFDataGetBytePtr(signature.get()),
@@ -887,7 +890,7 @@
 ConstBufferPtr
 SecTpmOsx::decryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool sym)
 {
-  throw Error("SecTpmOsx::decryptInTpm is not supported");
+  BOOST_THROW_EXCEPTION(Error("SecTpmOsx::decryptInTpm is not supported"));
 
   // KeyClass keyClass;
   // if (sym)
@@ -936,7 +939,8 @@
       CFReleaser<SecKeychainItemRef> privateKey = m_impl->getKey(keyName, keyClass);
       if (privateKey.get() == 0)
         {
-          throw Error("Private key [" + keyName.toUri() + "] does not exist in OSX Keychain");
+          BOOST_THROW_EXCEPTION(Error("Private key [" + keyName.toUri() + "] does not exist "
+                                      "in OSX Keychain"));
         }
 
       CFReleaser<SecAccessRef> accRef;
@@ -978,7 +982,7 @@
 ConstBufferPtr
 SecTpmOsx::encryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool sym)
 {
-  throw Error("SecTpmOsx::encryptInTpm is not supported");
+  BOOST_THROW_EXCEPTION(Error("SecTpmOsx::encryptInTpm is not supported"));
 
   // KeyClass keyClass;
   // if (sym)
