Fix catchIter

This commit is contained in:
Michael Snoyman 2011-10-06 16:51:20 +02:00
parent f5b5dc9b10
commit e5a44cfc8e
4 changed files with 9 additions and 4 deletions

View File

@ -119,7 +119,6 @@ import Yesod.Internal
import Data.Time (UTCTime)
import Control.Exception hiding (Handler, catch, finally)
import qualified Control.Exception as E
import Control.Applicative
import Control.Monad (liftM, join, MonadPlus)

View File

@ -11,7 +11,7 @@ module Yesod.Internal.TestApi
import Yesod.Internal.Request (randomString, parseWaiRequest')
import Control.Exception (Exception, catch)
import Data.Enumerator (Iteratee (..))
import Data.Enumerator (Iteratee (..), Step (..))
import Data.ByteString (ByteString)
import Prelude hiding (catch)
@ -19,4 +19,9 @@ catchIter :: Exception e
=> Iteratee ByteString IO a
-> (e -> Iteratee ByteString IO a)
-> Iteratee ByteString IO a
catchIter (Iteratee mstep) f = Iteratee $ mstep `catch` (runIteratee . f)
catchIter (Iteratee mstep) f = Iteratee $ do
step <- mstep `catch` (runIteratee . f)
return $ case step of
Continue k -> Continue $ \s -> catchIter (k s) f
Yield b s -> Yield b s
Error e -> Error e

View File

@ -100,7 +100,7 @@ caseAfter = runner $ do
, simpleRequestBody = content
}
assertStatus 500 res
assertBodyContains "There was an error 2.71828" res
assertBodyContains "bin12345" res
caseCatchIter :: IO ()
caseCatchIter = E.run_ $ E.enumList 8 (replicate 1000 "foo") E.$$ flip catchIter ignorer $ do

View File

@ -121,6 +121,7 @@ test-suite runtests
, random
,HUnit
,QuickCheck >= 2 && < 3
, enumerator
ghc-options: -Wall
source-repository head