@@ -37,7 +37,7 @@ module Database.PostgreSQL.Simple.Notification
3737 ) where
3838
3939import Control.Monad ( join, void )
40−import Control.Exception ( throwIO, try )
40+import Control.Exception ( throwIO, catch )
4141import qualified Data.ByteString as B
4242import qualified Data.ByteString.Char8 as B8
4343import Database.PostgreSQL.Simple.Internal
@@ -107,10 +107,8 @@ getNotification conn = join $ withConnection conn fetch
107107 -- unlucky, then we could end up waiting a long time.
108108 Just fd -> do
109109 return $ do
110− merr <- try (threadWaitRead fd)
111− case merr of
112− Left err -> throwIO $! setLoc err
113− Right _ -> loop
110+ threadWaitRead fd `catch` (throwIO . setIOErrorLocation)
111+ loop
114112#else
115113 -- This case fixes the race condition above. By registering
116114 -- our interest in the descriptor before we drop the lock,
@@ -124,18 +122,16 @@ getNotification conn = join $ withConnection conn fetch
124122 Just fd -> do
125123 (waitRead, _) <- threadWaitReadSTM fd
126124 return $ do
127− merr <- try (atomically waitRead)
128− case merr of
129− Left err -> throwIO $! setLoc err
130− Right _ -> loop
125+ atomically waitRead `catch` (throwIO . setIOErrorLocation)
126+ loop
131127#endif
132128
133129 loop = join $ withConnection conn $ \c -> do
134130 void $ PQ.consumeInput c
135131 fetch c
136132
137− setLoc :: IOError -> IOError
138− setLoc err = err { ioe_location = B8.unpack funcName }
133+ setIOErrorLocation :: IOError -> IOError
134+ setIOErrorLocation err = err { ioe_location = B8.unpack funcName }
139135
140136
141137-- | Non-blocking variant of 'getNotification'. Returns a single notification,