diff --git a/Data/Conduit/Zlib.hs b/Data/Conduit/Zlib.hs
--- a/Data/Conduit/Zlib.hs
+++ b/Data/Conduit/Zlib.hs
@@ -12,25 +12,35 @@
 ) where
 
 import Codec.Zlib
-import Data.Conduit
+import Data.Conduit hiding (unsafeLiftIO)
+import qualified Data.Conduit as C
 import Data.ByteString (ByteString)
 import qualified Data.ByteString as S
+import Control.Exception (try)
+import Control.Monad ((<=<))
 
 -- | Gzip compression with default parameters.
-gzip :: MonadUnsafeIO m => Conduit ByteString m ByteString
+gzip :: (MonadThrow m, MonadUnsafeIO m) => Conduit ByteString m ByteString
 gzip = compress 1 (WindowBits 31)
 
 -- | Gzip decompression with default parameters.
-ungzip :: MonadUnsafeIO m => Conduit ByteString m ByteString
+ungzip :: (MonadUnsafeIO m, MonadThrow m) => Conduit ByteString m ByteString
 ungzip = decompress (WindowBits 31)
 
+unsafeLiftIO :: (MonadUnsafeIO m, MonadThrow m) => IO a -> m a
+unsafeLiftIO =
+    either rethrow return <=< C.unsafeLiftIO . try
+  where
+    rethrow :: MonadThrow m => ZlibException -> m a
+    rethrow = monadThrow
+
 -- |
 -- Decompress (inflate) a stream of 'ByteString's. For example:
 --
 -- >    sourceFile "test.z" $= decompress defaultWindowBits $$ sinkFile "test"
 
 decompress
-    :: MonadUnsafeIO m
+    :: (MonadUnsafeIO m, MonadThrow m)
     => WindowBits -- ^ Zlib parameter (see the zlib-bindings package as well as the zlib C library)
     -> Conduit ByteString m ByteString
 decompress config = NeedInput
@@ -54,7 +64,7 @@
 
 -- | Same as 'decompress', but allows you to explicitly flush the stream.
 decompressFlush
-    :: MonadUnsafeIO m
+    :: (MonadUnsafeIO m, MonadThrow m)
     => WindowBits -- ^ Zlib parameter (see the zlib-bindings package as well as the zlib C library)
     -> Conduit (Flush ByteString) m (Flush ByteString)
 decompressFlush config = NeedInput
@@ -91,7 +101,7 @@
 -- the format (zlib vs. gzip).
 
 compress
-    :: MonadUnsafeIO m
+    :: (MonadUnsafeIO m, MonadThrow m)
     => Int         -- ^ Compression level
     -> WindowBits  -- ^ Zlib parameter (see the zlib-bindings package as well as the zlib C library)
     -> Conduit ByteString m ByteString
@@ -109,7 +119,7 @@
 
 -- | Same as 'compress', but allows you to explicitly flush the stream.
 compressFlush
-    :: MonadUnsafeIO m
+    :: (MonadUnsafeIO m, MonadThrow m)
     => Int         -- ^ Compression level
     -> WindowBits  -- ^ Zlib parameter (see the zlib-bindings package as well as the zlib C library)
     -> Conduit (Flush ByteString) m (Flush ByteString)
@@ -131,7 +141,7 @@
             Nothing -> Done Nothing ()
             Just chunk -> HaveOutput (Done Nothing ()) (return ()) (Chunk chunk)
 
-goPopper :: MonadUnsafeIO m
+goPopper :: (MonadUnsafeIO m, MonadThrow m)
          => (input -> Conduit input m output)
          -> Conduit input m output
          -> (S.ByteString -> output)
diff --git a/test/main.hs b/test/main.hs
--- a/test/main.hs
+++ b/test/main.hs
@@ -10,6 +10,7 @@
 import qualified Data.ByteString as S
 import qualified Data.ByteString.Lazy as L
 import Data.ByteString.Lazy.Char8 ()
+import Control.Monad.Trans.Resource (runExceptionT_)
 
 main :: IO ()
 main = hspecX $ do
@@ -18,13 +19,14 @@
             let bss = map S.pack bss'
                 lbs = L.fromChunks bss
                 src = mconcat $ map (CL.sourceList . return) bss
-            outBss <- src C.$= CZ.gzip C.$= CZ.ungzip C.$$ CL.consume
+            outBss <- runExceptionT_ $ src C.$= CZ.gzip C.$= CZ.ungzip C.$$ CL.consume
             return $ lbs == L.fromChunks outBss
         prop "flush" $ \bss' -> runST $ do
             let bss = map S.pack $ filter (not . null) bss'
                 bssC = concatMap (\bs -> [C.Chunk bs, C.Flush]) bss
                 src = mconcat $ map (CL.sourceList . return) bssC
-            outBssC <- src C.$= CZ.compressFlush 5 (CZ.WindowBits 31)
+            outBssC <- runExceptionT_
+                     $ src C.$= CZ.compressFlush 5 (CZ.WindowBits 31)
                            C.$= CZ.decompressFlush (CZ.WindowBits 31)
                            C.$$ CL.consume
             return $ bssC == outBssC
diff --git a/zlib-conduit.cabal b/zlib-conduit.cabal
--- a/zlib-conduit.cabal
+++ b/zlib-conduit.cabal
@@ -1,5 +1,5 @@
 Name:                zlib-conduit
-Version:             0.4.0
+Version:             0.4.0.1
 Synopsis:            Streaming compression/decompression via conduits.
 Description:         Streaming compression/decompression via conduits.
 License:             BSD3
@@ -37,6 +37,7 @@
                    , bytestring
                    , transformers
                    , zlib-conduit
+                   , resourcet
     ghc-options:     -Wall
 
 source-repository head
