Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Some useful functions if you want to wrap the ServerPartT
monad transformer around the ErrorT
monad transformer. e.g.,
. This allows you to use ServerPartT
(ErrorT
e m) athrowError
and catchError
inside your monad.
Synopsis
- spUnwrapErrorT :: Monad m => (e -> ServerPartT m a) -> Request -> UnWebT (ExceptT e m) a -> UnWebT m a
- simpleErrorHandler :: Monad m => String -> ServerPartT m Response
- errorHandlerSP :: Monad m => (Request -> e -> WebT m a) -> ServerPartT (ExceptT e m) a -> ServerPartT m a
Documentation
spUnwrapErrorT :: Monad m => (e -> ServerPartT m a) -> Request -> UnWebT (ExceptT e m) a -> UnWebT m a Source #
Flatten
into a ServerPartT
(ErrorT
e m) a
so that it can be use with ServerPartT
m
asimpleHTTP
. Used with
mapServerPartT'
, e.g.,
simpleHTTP conf $ mapServerPartT' (spUnWrapErrorT simpleErrorHandler) $ myPart `catchError` errorPart
Note that in this example, simpleErrorHandler
will only be run if errorPart
throws an error. You can replace simpleErrorHandler
with your own custom error handler.
see also: simpleErrorHandler
simpleErrorHandler :: Monad m => String -> ServerPartT m Response Source #
A simple error handler which can be used with spUnwrapErrorT
.
It returns the error message as a plain text message to the browser. More sophisticated behaviour can be achieved by calling your own custom error handler instead.
see also: spUnwrapErrorT
errorHandlerSP :: Monad m => (Request -> e -> WebT m a) -> ServerPartT (ExceptT e m) a -> ServerPartT m a Source #
Deprecated: Use spUnwrapErrorT
This ServerPart
modifier enables the use of throwError
and
catchError
inside the WebT
actions, by adding the ErrorT
monad transformer to the stack.
You can wrap the complete second argument to simpleHTTP
in this
function.
DEPRECATED: use spUnwrapErrorT
instead.