aboutsummaryrefslogtreecommitdiff
path: root/src/BTLS/Result.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/BTLS/Result.hs')
-rw-r--r--src/BTLS/Result.hs12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/BTLS/Result.hs b/src/BTLS/Result.hs
index b9ad4a7..6cac7b9 100644
--- a/src/BTLS/Result.hs
+++ b/src/BTLS/Result.hs
@@ -15,13 +15,11 @@
module BTLS.Result where
import Control.Exception (assert)
-import Foreign (throwIf_)
+import Control.Monad (when)
import Foreign.C.Types
-alwaysSucceeds :: IO CInt -> IO ()
-alwaysSucceeds f = do
- r <- f
- assert (r == 1) (return ())
+alwaysSucceeds :: CInt -> IO ()
+alwaysSucceeds r = assert (r == 1) (return ())
-requireSuccess :: IO CInt -> IO ()
-requireSuccess f = throwIf_ (/= 1) (const "BoringSSL failure") f
+requireSuccess :: CInt -> IO ()
+requireSuccess r = when (r /= 1) $ ioError (userError "BoringSSL failure")