mirror of
https://github.com/typeable/wai.git
synced 2025-01-07 14:51:40 +03:00
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:
commit
653b570268
@ -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 }
|
||||
|
Loading…
Reference in New Issue
Block a user