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

Safe Haskell | None
Language | Haskell2010

Servant.Server.Internal.ServerError

Synopsis

- data ServerError = ServerError {
  - errHTTPCode :: Int
  - errReasonPhrase :: String
  - errBody :: ByteString
  - errHeaders :: [Header]
  }
- responseServerError :: ServerError -> Response
- err300 :: ServerError
- err301 :: ServerError
- err302 :: ServerError
- err303 :: ServerError
- err304 :: ServerError
- err305 :: ServerError
- err307 :: ServerError
- err400 :: ServerError
- err401 :: ServerError
- err402 :: ServerError
- err403 :: ServerError
- err404 :: ServerError
- err405 :: ServerError
- err406 :: ServerError
- err407 :: ServerError
- err409 :: ServerError
- err410 :: ServerError
- err411 :: ServerError
- err412 :: ServerError
- err413 :: ServerError
- err414 :: ServerError
- err415 :: ServerError
- err416 :: ServerError
- err417 :: ServerError
- err418 :: ServerError
- err422 :: ServerError
- err429 :: ServerError
- err500 :: ServerError
- err501 :: ServerError
- err502 :: ServerError
- err503 :: ServerError
- err504 :: ServerError
- err505 :: ServerError

# Documentation

data ServerError Source #

Constructors

ServerError |

Fields

- errHTTPCode :: Int
- errReasonPhrase :: String
- errBody :: ByteString
- errHeaders :: [Header]

#### Instances

Instances details

Exception ServerError Source # |
Instance details Defined in Servant.Server.Internal.ServerError Methods toException :: ServerError -> SomeException Source # fromException :: SomeException -> Maybe ServerError Source # displayException :: ServerError -> String Source # backtraceDesired :: ServerError -> Bool Source #
Read ServerError Source # |
Instance details Defined in Servant.Server.Internal.ServerError Methods readsPrec :: Int -> ReadS ServerError Source # readList :: ReadS [ServerError] Source # readPrec :: ReadPrec ServerError Source # readListPrec :: ReadPrec [ServerError] Source #
Show ServerError Source # |
Instance details Defined in Servant.Server.Internal.ServerError Methods showsPrec :: Int -> ServerError -> ShowS Source # show :: ServerError -> String Source # showList :: [ServerError] -> ShowS Source #
Eq ServerError Source # |
Instance details Defined in Servant.Server.Internal.ServerError Methods (==) :: ServerError -> ServerError -> Bool Source # (/=) :: ServerError -> ServerError -> Bool Source #
MonadError ServerError Handler Source # |
Instance details Defined in Servant.Server.Internal.Handler Methods throwError :: ServerError -> Handler a Source # catchError :: Handler a -> (ServerError -> Handler a) -> Handler a Source #

responseServerError :: ServerError -> Response Source #

err300 :: ServerError Source #

`err300` Multiple Choices

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err300 { errBody = "I can't choose." }

err301 :: ServerError Source #

`err301` Moved Permanently

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err301

err302 :: ServerError Source #

`err302` Found

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err302

err303 :: ServerError Source #

`err303` See Other

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err303

err304 :: ServerError Source #

`err304` Not Modified

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err304

err305 :: ServerError Source #

`err305` Use Proxy

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err305

err307 :: ServerError Source #

`err307` Temporary Redirect

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err307

err400 :: ServerError Source #

`err400` Bad Request

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err400 { errBody = "Your request makes no sense to me." }

err401 :: ServerError Source #

`err401` Unauthorized

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err401 { errBody = "Your credentials are invalid." }

err402 :: ServerError Source #

`err402` Payment Required

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err402 { errBody = "You have 0 credits. Please give me $$$." }

err403 :: ServerError Source #

`err403` Forbidden

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err403 { errBody = "Please login first." }

err404 :: ServerError Source #

`err404` Not Found

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err404 { errBody = "Are you lost?" }

err405 :: ServerError Source #

`err405` Method Not Allowed

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err405 { errBody = "Your account privileges does not allow for this.  Please pay $$$." }

err406 :: ServerError Source #

`err406` Not Acceptable

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err406

err407 :: ServerError Source #

`err407` Proxy Authentication Required

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err407

err409 :: ServerError Source #

`err409` Conflict

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err409 { errBody = "Transaction conflicts with 59879cb56c7c159231eeacdd503d755f7e835f74" }

err410 :: ServerError Source #

`err410` Gone

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err410 { errBody = "I know it was here at some point, but.. I blame bad luck." }

err411 :: ServerError Source #

`err411` Length Required

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err411

err412 :: ServerError Source #

`err412` Precondition Failed

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err412 { errBody = "Precondition fail: x < 42 && y > 57" }

err413 :: ServerError Source #

`err413` Request Entity Too Large

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err413 { errBody = "Request exceeded 64k." }

err414 :: ServerError Source #

`err414` Request-URI Too Large

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err414 { errBody = "Maximum length is 64." }

err415 :: ServerError Source #

`err415` Unsupported Media Type

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err415 { errBody = "Supported media types:  gif, png" }

err416 :: ServerError Source #

`err416` Request range not satisfiable

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err416 { errBody = "Valid range is [0, 424242]." }

err417 :: ServerError Source #

`err417` Expectation Failed

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err417 { errBody = "I found a quux in the request.  This isn't going to work." }

err418 :: ServerError Source #

`err418` Expectation Failed

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err418 { errBody = "Apologies, this is not a webserver but a teapot." }

err422 :: ServerError Source #

`err422` Unprocessable Entity

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err422 { errBody = "I understood your request, but can't process it." }

err429 :: ServerError Source #

`err429` Too Many Requests

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err429 { errBody = "You have sent too many requests in a short period of time." }

err500 :: ServerError Source #

`err500` Internal Server Error

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err500 { errBody = "Exception in module A.B.C:55.  Have a great day!" }

err501 :: ServerError Source #

`err501` Not Implemented

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err501 { errBody = "/v1/foo is not supported with quux in the request." }

err502 :: ServerError Source #

`err502` Bad Gateway

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err502 { errBody = "Tried gateway foo, bar, and baz.  None responded." }

err503 :: ServerError Source #

`err503` Service Unavailable

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err503 { errBody = "We're rewriting in PHP." }

err504 :: ServerError Source #

`err504` Gateway Time-out

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err504 { errBody = "Backend foobar did not respond in 5 seconds." }

err505 :: ServerError Source #

`err505` HTTP Version not supported

Example usage:

    failingHandler :: Handler ()
    failingHandler = throwError $ err505 { errBody = "I support HTTP/4.0 only." }