happstack-server-7.9.0: Web related tools and services.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Happstack.Server.Error

Description

Some useful functions if you want to wrap the ServerPartT monad transformer around the ErrorT monad transformer. e.g., ServerPartT (ErrorT e m) a. This allows you to use throwError and catchError inside your monad.

Synopsis

Documentation

spUnwrapErrorT :: Monad m => (e -> ServerPartT m a) -> Request -> UnWebT (ExceptT e m) a -> UnWebT m a Source #

Flatten ServerPartT (ErrorT e m) a into a ServerPartT m a so that it can be use with simpleHTTP. 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.