Fix catchIter
This commit is contained in:
parent
f5b5dc9b10
commit
e5a44cfc8e
@ -119,7 +119,6 @@ import Yesod.Internal
|
|||||||
import Data.Time (UTCTime)
|
import Data.Time (UTCTime)
|
||||||
|
|
||||||
import Control.Exception hiding (Handler, catch, finally)
|
import Control.Exception hiding (Handler, catch, finally)
|
||||||
import qualified Control.Exception as E
|
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
|
|
||||||
import Control.Monad (liftM, join, MonadPlus)
|
import Control.Monad (liftM, join, MonadPlus)
|
||||||
|
|||||||
@ -11,7 +11,7 @@ module Yesod.Internal.TestApi
|
|||||||
|
|
||||||
import Yesod.Internal.Request (randomString, parseWaiRequest')
|
import Yesod.Internal.Request (randomString, parseWaiRequest')
|
||||||
import Control.Exception (Exception, catch)
|
import Control.Exception (Exception, catch)
|
||||||
import Data.Enumerator (Iteratee (..))
|
import Data.Enumerator (Iteratee (..), Step (..))
|
||||||
import Data.ByteString (ByteString)
|
import Data.ByteString (ByteString)
|
||||||
import Prelude hiding (catch)
|
import Prelude hiding (catch)
|
||||||
|
|
||||||
@ -19,4 +19,9 @@ catchIter :: Exception e
|
|||||||
=> Iteratee ByteString IO a
|
=> Iteratee ByteString IO a
|
||||||
-> (e -> Iteratee ByteString IO a)
|
-> (e -> Iteratee ByteString IO a)
|
||||||
-> 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
|
||||||
|
|||||||
@ -100,7 +100,7 @@ caseAfter = runner $ do
|
|||||||
, simpleRequestBody = content
|
, simpleRequestBody = content
|
||||||
}
|
}
|
||||||
assertStatus 500 res
|
assertStatus 500 res
|
||||||
assertBodyContains "There was an error 2.71828" res
|
assertBodyContains "bin12345" res
|
||||||
|
|
||||||
caseCatchIter :: IO ()
|
caseCatchIter :: IO ()
|
||||||
caseCatchIter = E.run_ $ E.enumList 8 (replicate 1000 "foo") E.$$ flip catchIter ignorer $ do
|
caseCatchIter = E.run_ $ E.enumList 8 (replicate 1000 "foo") E.$$ flip catchIter ignorer $ do
|
||||||
|
|||||||
@ -121,6 +121,7 @@ test-suite runtests
|
|||||||
, random
|
, random
|
||||||
,HUnit
|
,HUnit
|
||||||
,QuickCheck >= 2 && < 3
|
,QuickCheck >= 2 && < 3
|
||||||
|
, enumerator
|
||||||
ghc-options: -Wall
|
ghc-options: -Wall
|
||||||
|
|
||||||
source-repository head
|
source-repository head
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user