diff --git a/Network/IRC/Client/Internal.hs b/Network/IRC/Client/Internal.hs
--- a/Network/IRC/Client/Internal.hs
+++ b/Network/IRC/Client/Internal.hs
@@ -1,6 +1,7 @@
-{-# LANGUAGE CPP                #-}
-{-# LANGUAGE ImpredicativeTypes #-}
-{-# LANGUAGE OverloadedStrings  #-}
+{-# LANGUAGE CPP                 #-}
+{-# LANGUAGE OverloadedStrings   #-}
+{-# LANGUAGE RankNTypes          #-}
+{-# LANGUAGE ScopedTypeVariables #-}
 
 -- | Most of the hairy code. This isn't all internal, due to messy
 -- dependencies, but I've tried to make this as \"internal\" as
@@ -10,6 +11,7 @@
 import Control.Applicative        ((<$>))
 import Control.Concurrent         (forkIO)
 import Control.Concurrent.STM     (atomically, readTVar, retry)
+import Control.Exception          (SomeException, catch, throwIO)
 import Control.Monad              (unless)
 import Control.Monad.IO.Class     (MonadIO, liftIO)
 import Control.Monad.Trans.Reader (runReaderT)
@@ -79,12 +81,13 @@
 
   -- Run the event loop, and call the disconnect handler if the remote
   -- end closes the socket.
-  flood  <- _flood     <$> connectionConfig
-  func   <- _func      <$> connectionConfig
-  logf   <- _logfunc   <$> connectionConfig
-  port   <- _port      <$> connectionConfig
-  queue  <- _sendqueue <$> connectionConfig
-  server <- _server    <$> connectionConfig
+  cconf <- connectionConfig
+  let flood  = _flood     cconf
+  let func   = _func      cconf
+  let logf   = _logfunc   cconf
+  let port   = _port      cconf
+  let queue  = _sendqueue cconf
+  let server = _server    cconf
 
   antiflood <- liftIO $ floodProtector flood
 
@@ -93,10 +96,15 @@
   let source = toProducer $ sourceTBMChan queue $= antiflood $= logConduit (logf FromClient . toByteString)
   let sink   = forgetful =$= logConduit (logf FromServer . _raw) =$ eventSink state
 
-  liftIO $ func port server initialise sink source
+  (exc :: Maybe SomeException) <- liftIO $ catch
+    (func port server initialise sink source >> pure Nothing)
+    (pure . Just)
 
   disconnect
   dchandler
+
+  -- If the connection terminated due to an exception, rethrow it.
+  liftIO $ maybe (pure ()) throwIO exc
 
 -- | Forget failed decodings.
 forgetful :: Monad m => Conduit (Either a b) m b
diff --git a/Network/IRC/Client/Types.hs b/Network/IRC/Client/Types.hs
--- a/Network/IRC/Client/Types.hs
+++ b/Network/IRC/Client/Types.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE ImpredicativeTypes #-}
+{-# LANGUAGE RankNTypes #-}
 
 -- | Types for IRC clients. See also
 -- <http://hackage.haskell.org/package/irc-conduit/docs/Network-IRC-Conduit.html Network.IRC.Conduit> and
diff --git a/irc-client.cabal b/irc-client.cabal
--- a/irc-client.cabal
+++ b/irc-client.cabal
@@ -10,7 +10,7 @@
 -- PVP summary:      +-+------- breaking API changes
 --                   | | +----- non-breaking API additions
 --                   | | | +--- code changes with no API change
-version:             0.3.0.0
+version:             0.4.0.0
 
 -- A short (one-line) description of the package.
 synopsis:            An IRC client library.
@@ -82,18 +82,18 @@
   -- other-extensions:    
   
   -- Other library packages from which modules are imported.
-  build-depends:       base         >=4.7 && <5
-                     , bytestring   >=0.10
-                     , conduit      >=1.2
-                     , data-default-class >=0.0.1
-                     , irc-conduit  >=0.1.1
-                     , irc-ctcp     >=0.1.2
-                     , old-locale   >=1.0
-                     , stm          >=2.4
-                     , stm-conduit  >=2.5
-                     , text         >=1.1
-                     , time         >=1.4
-                     , transformers >=0.3
+  build-depends:       base               >=4.7   && <5
+                     , bytestring         >=0.10  && <0.11
+                     , conduit            >=1.2   && <1.3
+                     , data-default-class >=0.0.1 && <0.1
+                     , irc-conduit        >=0.1.1 && <0.3
+                     , irc-ctcp           >=0.1.2 && <0.2
+                     , old-locale         >=1.0   && <1.1
+                     , stm                >=2.4   && <2.5
+                     , stm-conduit        >=2.5   && <3.1
+                     , text               >=1.1   && <1.3
+                     , time               >=1.4   && <1.7
+                     , transformers       >=0.3   && <0.6
   
   -- Directories containing source files.
   -- hs-source-dirs:      
@@ -108,4 +108,4 @@
 source-repository this
   type:     git
   location: https://github.com/barrucadu/irc-client.git
-  tag:      0.3.0.0
+  tag:      0.4.0.0
