| Copyright | Dennis Gosnell 2017 |
|---|---|
| License | BSD3 |
| Maintainer | Dennis Gosnell (cdep.illabout@gmail.com) |
| Stability | experimental |
| Portability | unknown |
| Safe Haskell | None |
| Language | Haskell2010 |
Servant.Checked.Exceptions.Internal.Servant.API
Synopsis
- data Throws (e :: *)
- data NoThrow
- data Throwing (e :: [*])
- type family ThrowingNonterminal api where ...
- class ErrStatus e where
- toErrStatus :: e -> Status
- type family AllErrStatus (es :: [k]) :: Constraint where ...
Documentation
Throws is used in Servant API definitions and signifies that an API will
throw the given error.
Here is an example of how to create an API that potentially returns a
String as an error, or an Int on success:
>>>import Servant.API (Get, JSON, (:>))>>>type API = Throws String :> Get '[JSON] Int
NoThrow is used to indicate that an API will not throw an error, but
that it will still return a response wrapped in a
Envelope.
Examples
Create an API using NoThrow:
>>>import Servant.API (Get, JSON, (:>))>>>type API = NoThrow :> Get '[JSON] Int
A servant-server handler for this type would look like the following:
apiHandler ::Handler(Envelope'[] Int) apiHandler =pureSuccEnvelope3
data Throwing (e :: [*]) Source #
This is used internally and should not be used by end-users.
Instances
| HasDocs (Throwing (Snoc es e) :> api) => HasDocs (Throwing es :> (Throws e :> api) :: Type) Source # | When a |
| (CreateRespBodiesFor es ctypes, HasDocs (Verb method status ctypes (Envelope es a))) => HasDocs (Throwing es :> Verb method status ctypes a :: Type) Source # | When |
type family ThrowingNonterminal api where ... Source #
type family AllErrStatus (es :: [k]) :: Constraint where ... Source #
Equations
| AllErrStatus '[] = () | |
| AllErrStatus (a ': as) = (ErrStatus a, AllErrStatus as) |
>>>:set -XDataKinds>>>:set -XTypeOperators