servant-server-0.18: A family of combinators for defining webservices APIs and serving them

Safe HaskellNone
LanguageHaskell2010

Servant.Server.Internal.ErrorFormatter

Synopsis

Documentation

data ErrorFormatters Source #

A collection of error formatters for different situations.

If you need to override one of them, use defaultErrorFormatters with record update syntax.

Constructors

ErrorFormatters 

Fields

type ErrorFormatter = TypeRep -> Request -> String -> ServerError Source #

A custom formatter for errors produced by parsing combinators like ReqBody or Capture.

A TypeRep argument described the concrete combinator that raised the error, allowing formatter to customize the message for different combinators.

A full Request is also passed so that the formatter can react to Accept header, for example.

type NotFoundErrorFormatter = Request -> ServerError Source #

This formatter does not get neither TypeRep nor error message.

type DefaultErrorFormatters = '[ErrorFormatters] Source #

Context that contains default error formatters.

defaultErrorFormatters :: ErrorFormatters Source #

Default formatters will just return HTTP 400 status code with error message as response body.