| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Servant.Util.Combinators.ErrorResponses
Synopsis
- data ErrorDesc = ErrorDesc {}
- data ErrorPartialDesc = ErrorPartialDesc {}
- data ErrorResponses (errs :: [ErrorDesc])
- type (#:) = 'ErrorPartialDesc
- type ($) (f :: k1 -> k) (a :: k1) = f a
- type ExceptionalResponses err codes = ErrorResponses $ ExceptionDesc err codes
Documentation
Type-level information about an error response.
data ErrorPartialDesc Source #
Like ErrorDesc, but without exception type yet.
Constructors
| ErrorPartialDesc | |
data ErrorResponses (errs :: [ErrorDesc]) Source #
This combinator adds description of error response to swagger specification.
You have two ways to define this combinator:
- General:
ErrorResponses
'[ 404 #! MyBackendException $
"Not found"
, 403 #! Int $
"Operation is not permitted"
]
- When only one exception type is used:
ExceptionalResponses MyBackendException
'[ 404 #: "Not found"
, 403 #: "Operation is not permitted"
]
Note that if an error code was already defined further in endpoint definition,
it will be overwriten. For instance, Captures define 400 error code (invalid
format); but in endpoint like ErrorResponses (400 ...) :> Capture ... :> ...
description for 400-error case provided by Capture will be overwritten.
This combinator is transparent for server implementation.
Instances
type (#:) = 'ErrorPartialDesc Source #
A convenient alias for use with ExceptionalResponse.
type ($) (f :: k1 -> k) (a :: k1) = f a infixr 2 #
Infix application.
f :: Either String $ Maybe Int = f :: Either String (Maybe Int)
type ExceptionalResponses err codes = ErrorResponses $ ExceptionDesc err codes Source #
An alias for ErrorResponse which allows to mention an exception type
just once across all errors specification.