Merge pull request #557 from mkscrg/clarify-warp-ex-handling

warp: add example of normal exception handling to Warp.hs haddocks
This commit is contained in:
Michael Snoyman 2016-05-25 07:01:51 +03:00
commit 653b570268

View File

@ -138,9 +138,18 @@ setOnException :: (Maybe Request -> SomeException -> IO ()) -> Settings -> Setti
setOnException x y = y { settingsOnException = x }
-- | A function to create a `Response` when an exception occurs.
--
-- Default: 'defaultOnExceptionResponse'
--
-- Note that an application can handle its own exceptions without interfering with Warp:
--
-- > myApp :: Application
-- > myApp request respond = innerApp `catch` onError
-- > where
-- > onError = respond . response500 request
-- >
-- > response500 :: Request -> SomeException -> Response
-- > response500 req someEx = responseLBS status500 -- ...
--
-- Since 2.1.0
setOnExceptionResponse :: (SomeException -> Response) -> Settings -> Settings
setOnExceptionResponse x y = y { settingsOnExceptionResponse = x }