| Safe Haskell | None |
|---|
Network.Wai.Middleware.Catch
Contents
Description
Exception handling for Wai and Warp.
By default Warp not handles exceptions well. It just log them to
console. This package - an attempt to solve the problem.
The only drawback stems from the basic advantages of Haskell - laziness.
All errors within Wai ResponseBuilder will not be caught. Thus, the
following code will not work:
... return $ responseLBS undefined ...
To ensure catch all errors, you need to consume all data before feeding the builder.
- protect :: [ResponseHandler] -> Middleware
- protect' :: Exception e => [ResponseHandler] -> (e -> Application) -> Middleware
- data ResponseHandler = forall e . Exception e => ResponseHandler (e -> Application)
- mkHandler :: forall e. Exception e => (e -> Application) -> ResponseHandler
- defHandler :: SomeException -> Application
Middleware
Arguments
| :: [ResponseHandler] | Wrapped handlers. See |
| -> Middleware |
Protect Middleware chain from exceptions. This acts like
catches, but uses own handler type for simplicity.
If an exception is not handled, it is thrown further. To handle this
use protect'.
Arguments
| :: Exception e | |
| => [ResponseHandler] | Wrapped handlers. See |
| -> (e -> Application) | Default handler |
| -> Middleware |
"Harden" version of protect.
Handlers
data ResponseHandler Source
Handler wrapper. For polymorphic exceptions. If an exception is not handled, it is thrown to default handler.
protect' [...] defHandler
Constructors
| forall e . Exception e => ResponseHandler (e -> Application) |
Arguments
| :: forall e . Exception e | |
| => (e -> Application) | |
| -> ResponseHandler |
Helper for make RequestHandler
protect [mkHandler myHandler] $ ...
defHandler :: SomeException -> ApplicationSource
Default handler.