servant-util-0.2: Servant servers utilities.
Safe HaskellNone
LanguageHaskell2010

Servant.Util.Combinators.ErrorResponses

Synopsis

Documentation

data ErrorDesc Source #

Type-level information about an error response.

Constructors

ErrorDesc 

Fields

data ErrorPartialDesc Source #

Like ErrorDesc, but without exception type yet.

Constructors

ErrorPartialDesc 

Fields

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

Instances details
HasClient m subApi => HasClient m (ErrorResponses errors :> subApi) Source # 
Instance details

Defined in Servant.Util.Combinators.ErrorResponses

Associated Types

type Client m (ErrorResponses errors :> subApi) #

Methods

clientWithRoute :: Proxy m -> Proxy (ErrorResponses errors :> subApi) -> Request -> Client m (ErrorResponses errors :> subApi) #

hoistClientMonad :: Proxy m -> Proxy (ErrorResponses errors :> subApi) -> (forall x. mon x -> mon' x) -> Client mon (ErrorResponses errors :> subApi) -> Client mon' (ErrorResponses errors :> subApi) #

HasLoggingServer config lcontext subApi ctx => HasLoggingServer (config :: Type) lcontext (ErrorResponses errors :> subApi :: Type) ctx Source # 
Instance details

Defined in Servant.Util.Combinators.ErrorResponses

Methods

routeWithLog :: Proxy (LoggingApiRec config lcontext (ErrorResponses errors :> subApi)) -> Context ctx -> Delayed env (Server (LoggingApiRec config lcontext (ErrorResponses errors :> subApi))) -> Router env Source #

(HasSwagger subApi, KnownErrorCodes errors) => HasSwagger (ErrorResponses errors :> subApi :: Type) Source # 
Instance details

Defined in Servant.Util.Combinators.ErrorResponses

Methods

toSwagger :: Proxy (ErrorResponses errors :> subApi) -> Swagger #

HasServer subApi ctx => HasServer (ErrorResponses errors :> subApi :: Type) ctx Source # 
Instance details

Defined in Servant.Util.Combinators.ErrorResponses

Associated Types

type ServerT (ErrorResponses errors :> subApi) m #

Methods

route :: Proxy (ErrorResponses errors :> subApi) -> Context ctx -> Delayed env (Server (ErrorResponses errors :> subApi)) -> Router env #

hoistServerWithContext :: Proxy (ErrorResponses errors :> subApi) -> Proxy ctx -> (forall x. m x -> n x) -> ServerT (ErrorResponses errors :> subApi) m -> ServerT (ErrorResponses errors :> subApi) n #

type Client m (ErrorResponses errors :> subApi) Source # 
Instance details

Defined in Servant.Util.Combinators.ErrorResponses

type Client m (ErrorResponses errors :> subApi) = Client m subApi
type ServerT (ErrorResponses errors :> subApi :: Type) m Source # 
Instance details

Defined in Servant.Util.Combinators.ErrorResponses

type ServerT (ErrorResponses errors :> subApi :: Type) m = ServerT subApi m

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.