Skip to content

Commit

Permalink
Catch exceptions by default in the default environments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastiaan Visser committed Sep 4, 2010
1 parent 33a0cb5 commit eb6c491
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/Network/Salvia/Handler/Environment.hs
Expand Up @@ -5,7 +5,7 @@ module Network.Salvia.Handler.Environment
)
where

import Control.Monad.State
import Control.Monad.CatchIO (MonadCatchIO)
import Network.Protocol.Http
import Network.Salvia.Interface
import Network.Salvia.Handler.Banner
Expand All @@ -24,11 +24,11 @@ keep-alives (`hKeepAlive`), handling `HEAD` requests (`hHead`) and printing the
-}

hDefaultEnv
:: (MonadIO m, HandleM m, RawHttpM' m, HttpM' m, QueueM m, SendM m, FlushM Response m)
:: (MonadCatchIO m, HandleM m, RawHttpM' m, HttpM' m, QueueM m, SendM m, FlushM Response m)
=> m () -- ^ Handler to run in the default environment.
-> m ()
hDefaultEnv handler =
hKeepAlive $
hKeepAlive . hCatchAnd500 $
do hBanner "salvia-httpd"
_ <- hRequestParser (1000 * 4)
(hCustomError BadRequest)
Expand All @@ -38,13 +38,14 @@ hDefaultEnv handler =
-- | Like `hDefaultEnv' but only serves one request per connection.

hEnvNoKeepAlive
:: (MonadIO m, HandleM m, RawHttpM' m, HttpM' m, QueueM m, SendM m, FlushM Response m)
:: (MonadCatchIO m, HandleM m, RawHttpM' m, HttpM' m, QueueM m, SendM m, FlushM Response m)
=> m () -- ^ Handler to run in this environment.
-> m ()
hEnvNoKeepAlive handler =
do hBanner "salvia-httpd"
_ <- hRequestParser (1000 * 4)
(hCustomError BadRequest)
(hHead handler)
hResponsePrinter
hCatchAnd500 $
do hBanner "salvia-httpd"
_ <- hRequestParser (1000 * 4)
(hCustomError BadRequest)
(hHead handler)
hResponsePrinter

0 comments on commit eb6c491

Please sign in to comment.