git.iko.soy/typeable/servant
on master help sign in
Merge pull request #1131 from phadej/error-renaming

Rename ServantError to ClientError, ServantErr to ServerError

commit3db3d38e14a803c11f13782a23aba3da6c7de570 authorOleg Grenrus <oleg.grenrus@iki.fi> dateMon 18 Feb 2019, 23:15 (8 years ago) parente922b98a5655f8
25 files changed+162−166
.travis.yml+3−9 cabal.project+3−3 doc/cookbook/testing/Testing.lhs+2−2 doc/tutorial/Server.lhs+6−6 servant-client-core/src/Servant/Client/Core.hs+1−1 servant-client-core/src/Servant/Client/Core/ClientError.hs+5−5 servant-client-core/src/Servant/Client/Core/HasClient.hs+4−4 servant-client-core/src/Servant/Client/Core/Reexport.hs+1−1 servant-client-core/src/Servant/Client/Core/RunClient.hs+3−3 servant-client-ghcjs/src/Servant/Client/Internal/XhrClient.hs+7−7 servant-client/src/Servant/Client/Internal/HttpClient.hs+7−7 servant-client/src/Servant/Client/Internal/HttpClient/Streaming.hs+5−5 servant-client/test/Servant/ClientSpec.hs+5−5 servant-client/test/Servant/StreamSpec.hs+1−1 servant-http-streams/src/Servant/HttpStreams/Internal.hs+7−7 servant-http-streams/test/Servant/ClientSpec.hs+6−6 servant-http-streams/test/Servant/StreamSpec.hs+1−1 servant-server/servant-server.cabal+1−1 servant-server/src/Servant/Server.hs+1−1 servant-server/src/Servant/Server/Internal.hs+2−2 servant-server/src/Servant/Server/Internal/BasicAuth.hs+1−1 servant-server/src/Servant/Server/Internal/Handler.hs+6−6 servant-server/src/Servant/Server/Internal/Router.hs+1−1 servant-server/src/Servant/Server/Internal/RoutingApplication.hs+8−8 servant-server/src/Servant/Server/Internal/ServantErr.hs → servant-server/src/Servant/Server/Internal/ServerError.hs+75−73
.travis.yml+3−9
@@ -87,9 +87,7 @@ install:
8787 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"doc/cookbook/db-sqlite-simple\"\\n' >> cabal.project ; fi"
8888 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"doc/cookbook/file-upload\"\\n' >> cabal.project ; fi"
8989 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"doc/cookbook/generic\"\\n' >> cabal.project ; fi"
90− - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"doc/cookbook/hoist-server-with-context\"\\n' >> cabal.project ; fi"
9190 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"doc/cookbook/https\"\\n' >> cabal.project ; fi"
92− - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"doc/cookbook/jwt-and-basic-auth\"\\n' >> cabal.project ; fi"
9391 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"doc/cookbook/testing\"\\n' >> cabal.project ; fi"
9492 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"doc/cookbook/structuring-apis\"\\n' >> cabal.project ; fi"
9593 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"doc/cookbook/using-custom-monad\"\\n' >> cabal.project ; fi"
@@ -106,7 +104,7 @@ install:
106104 - "echo 'reorder-goals: True' >> cabal.project"
107105 - "echo 'optimization: False' >> cabal.project "
108106 - touch cabal.project.local
109− - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | grep -vE -- '^(cookbook-basic-auth|cookbook-basic-streaming|cookbook-curl-mock|cookbook-db-postgres-pool|cookbook-db-sqlite-simple|cookbook-file-upload|cookbook-generic|cookbook-hoist-server-with-context|cookbook-https|cookbook-jwt-and-basic-auth|cookbook-structuring-apis|cookbook-testing|cookbook-using-custom-monad|cookbook-using-free-client|servant|servant-client|servant-client-core|servant-conduit|servant-docs|servant-foreign|servant-http-streams|servant-machines|servant-pipes|servant-server|tutorial)$' | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
107+ - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | grep -vE -- '^(cookbook-basic-auth|cookbook-basic-streaming|cookbook-curl-mock|cookbook-db-postgres-pool|cookbook-db-sqlite-simple|cookbook-file-upload|cookbook-generic|cookbook-https|cookbook-structuring-apis|cookbook-testing|cookbook-using-custom-monad|cookbook-using-free-client|servant|servant-client|servant-client-core|servant-conduit|servant-docs|servant-foreign|servant-http-streams|servant-machines|servant-pipes|servant-server|tutorial)$' | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
110108 - cat cabal.project || true
111109 - cat cabal.project.local || true
112110 - if [ -f "servant/configure.ac" ]; then (cd "servant" && autoreconf -i); fi
@@ -127,15 +125,13 @@ install:
127125 - if [ -f "doc/cookbook/db-sqlite-simple/configure.ac" ]; then (cd "doc/cookbook/db-sqlite-simple" && autoreconf -i); fi
128126 - if [ -f "doc/cookbook/file-upload/configure.ac" ]; then (cd "doc/cookbook/file-upload" && autoreconf -i); fi
129127 - if [ -f "doc/cookbook/generic/configure.ac" ]; then (cd "doc/cookbook/generic" && autoreconf -i); fi
130− - if [ -f "doc/cookbook/hoist-server-with-context/configure.ac" ]; then (cd "doc/cookbook/hoist-server-with-context" && autoreconf -i); fi
131128 - if [ -f "doc/cookbook/https/configure.ac" ]; then (cd "doc/cookbook/https" && autoreconf -i); fi
132− - if [ -f "doc/cookbook/jwt-and-basic-auth/configure.ac" ]; then (cd "doc/cookbook/jwt-and-basic-auth" && autoreconf -i); fi
133129 - if [ -f "doc/cookbook/testing/configure.ac" ]; then (cd "doc/cookbook/testing" && autoreconf -i); fi
134130 - if [ -f "doc/cookbook/structuring-apis/configure.ac" ]; then (cd "doc/cookbook/structuring-apis" && autoreconf -i); fi
135131 - if [ -f "doc/cookbook/using-custom-monad/configure.ac" ]; then (cd "doc/cookbook/using-custom-monad" && autoreconf -i); fi
136132 - if [ -f "doc/cookbook/using-free-client/configure.ac" ]; then (cd "doc/cookbook/using-free-client" && autoreconf -i); fi
137133 - rm -f cabal.project.freeze
138− - rm -rf .ghc.environment.* "servant"/dist "servant-client"/dist "servant-client-core"/dist "servant-http-streams"/dist "servant-docs"/dist "servant-foreign"/dist "servant-server"/dist "doc/tutorial"/dist "servant-machines"/dist "servant-conduit"/dist "servant-pipes"/dist "doc/cookbook/basic-auth"/dist "doc/cookbook/curl-mock"/dist "doc/cookbook/basic-streaming"/dist "doc/cookbook/db-postgres-pool"/dist "doc/cookbook/db-sqlite-simple"/dist "doc/cookbook/file-upload"/dist "doc/cookbook/generic"/dist "doc/cookbook/hoist-server-with-context"/dist "doc/cookbook/https"/dist "doc/cookbook/jwt-and-basic-auth"/dist "doc/cookbook/testing"/dist "doc/cookbook/structuring-apis"/dist "doc/cookbook/using-custom-monad"/dist "doc/cookbook/using-free-client"/dist
134+ - rm -rf .ghc.environment.* "servant"/dist "servant-client"/dist "servant-client-core"/dist "servant-http-streams"/dist "servant-docs"/dist "servant-foreign"/dist "servant-server"/dist "doc/tutorial"/dist "servant-machines"/dist "servant-conduit"/dist "servant-pipes"/dist "doc/cookbook/basic-auth"/dist "doc/cookbook/curl-mock"/dist "doc/cookbook/basic-streaming"/dist "doc/cookbook/db-postgres-pool"/dist "doc/cookbook/db-sqlite-simple"/dist "doc/cookbook/file-upload"/dist "doc/cookbook/generic"/dist "doc/cookbook/https"/dist "doc/cookbook/testing"/dist "doc/cookbook/structuring-apis"/dist "doc/cookbook/using-custom-monad"/dist "doc/cookbook/using-free-client"/dist
139135 - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
140136
141137# Here starts the actual work to be performed for the package under test;
@@ -169,9 +165,7 @@ script:
169165 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"cookbook-db-sqlite-simple-*/*.cabal\"\\n' >> cabal.project ; fi"
170166 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"cookbook-file-upload-*/*.cabal\"\\n' >> cabal.project ; fi"
171167 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"cookbook-generic-*/*.cabal\"\\n' >> cabal.project ; fi"
172− - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"cookbook-hoist-server-with-context-*/*.cabal\"\\n' >> cabal.project ; fi"
173168 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"cookbook-https-*/*.cabal\"\\n' >> cabal.project ; fi"
174− - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"cookbook-jwt-and-basic-auth-*/*.cabal\"\\n' >> cabal.project ; fi"
175169 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"cookbook-testing-*/*.cabal\"\\n' >> cabal.project ; fi"
176170 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"cookbook-structuring-apis-*/*.cabal\"\\n' >> cabal.project ; fi"
177171 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"cookbook-using-custom-monad-*/*.cabal\"\\n' >> cabal.project ; fi"
@@ -188,7 +182,7 @@ script:
188182 - "echo 'reorder-goals: True' >> cabal.project"
189183 - "echo 'optimization: False' >> cabal.project "
190184 - touch cabal.project.local
191− - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | grep -vE -- '^(cookbook-basic-auth|cookbook-basic-streaming|cookbook-curl-mock|cookbook-db-postgres-pool|cookbook-db-sqlite-simple|cookbook-file-upload|cookbook-generic|cookbook-hoist-server-with-context|cookbook-https|cookbook-jwt-and-basic-auth|cookbook-structuring-apis|cookbook-testing|cookbook-using-custom-monad|cookbook-using-free-client|servant|servant-client|servant-client-core|servant-conduit|servant-docs|servant-foreign|servant-http-streams|servant-machines|servant-pipes|servant-server|tutorial)$' | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
185+ - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | grep -vE -- '^(cookbook-basic-auth|cookbook-basic-streaming|cookbook-curl-mock|cookbook-db-postgres-pool|cookbook-db-sqlite-simple|cookbook-file-upload|cookbook-generic|cookbook-https|cookbook-structuring-apis|cookbook-testing|cookbook-using-custom-monad|cookbook-using-free-client|servant|servant-client|servant-client-core|servant-conduit|servant-docs|servant-foreign|servant-http-streams|servant-machines|servant-pipes|servant-server|tutorial)$' | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
192186 - cat cabal.project || true
193187 - cat cabal.project.local || true
194188 - echo -en 'travis_fold:end:unpack\\r'
cabal.project+3−3
@@ -21,11 +21,11 @@ packages:
2121 doc/cookbook/db-sqlite-simple
2222 doc/cookbook/file-upload
2323 doc/cookbook/generic
24− doc/cookbook/hoist-server-with-context
24+ -- doc/cookbook/hoist-server-with-context
2525 doc/cookbook/https
26− doc/cookbook/jwt-and-basic-auth/
26+ -- doc/cookbook/jwt-and-basic-auth/
2727 -- doc/cookbook/pagination
28− -- doc/cookbook/sentry
28+ -- doc/cookbook/sentry
2929 doc/cookbook/testing
3030 doc/cookbook/structuring-apis
3131 doc/cookbook/using-custom-monad
doc/cookbook/testing/Testing.lhs+2−2
@@ -234,7 +234,7 @@ clientEnv esHost esPort = do
234234 manager <- newManager defaultManagerSettings
235235 pure $ mkClientEnv manager baseUrl
236236
237−runSearchClient :: Text -> Text -> ClientM a -> IO (Either ServantError a)
237+runSearchClient :: Text -> Text -> ClientM a -> IO (Either ClientError a)
238238runSearchClient esHost esPort = (clientEnv esHost esPort >>=) . runClientM
239239```
240240
@@ -267,7 +267,7 @@ docServer esHost esPort = getDocById esHost esPort
267267-- actions
268268getDocById :: Text -> Text -> Integer -> Handler Value
269269getDocById esHost esPort docId = do
270− -- Our Servant Client function returns Either ServantError Value here:
270+ -- Our Servant Client function returns Either ClientError Value here:
271271 docRes <- liftIO $ runSearchClient esHost esPort (getDocument docId)
272272 case docRes of
273273 Left err -> throwError $ err404 { errBody = "Failed looking up content" }
doc/tutorial/Server.lhs+6−6
@@ -599,7 +599,7 @@ $ curl -H 'Accept: text/html' http://localhost:8081/persons
599599
600600## The `Handler` monad
601601
602−At the heart of the handlers is the monad they run in, namely a newtype `Handler` around `ExceptT ServantErr IO`
602+At the heart of the handlers is the monad they run in, namely a newtype `Handler` around `ExceptT ServerErroror IO`
603603([haddock documentation for `ExceptT`](http://hackage.haskell.org/package/mtl-2.2.1/docs/Control-Monad-Except.html#t:ExceptT)).
604604One might wonder: why this monad? The answer is that it is the
605605simplest monad with the following properties:
@@ -617,7 +617,7 @@ newtype ExceptT e m a = ExceptT (m (Either e a))
617617```
618618
619619In short, this means that a handler of type `Handler a` is simply
620−equivalent to a computation of type `IO (Either ServantErr a)`, that is, an IO
620+equivalent to a computation of type `IO (Either ServerError a)`, that is, an IO
621621action that either returns an error or a result.
622622
623623The module [`Control.Monad.Except`](https://hackage.haskell.org/package/mtl-2.2.1/docs/Control-Monad-Except.html#t:ExceptT)
@@ -660,16 +660,16 @@ server5 = do
660660 return (FileContent filecontent)
661661```
662662
663−### Failing, through `ServantErr`
663+### Failing, through `ServerError`
664664
665665If you want to explicitly fail at providing the result promised by an endpoint
666666using the appropriate HTTP status code (not found, unauthorized, etc) and some
667667error message, all you have to do is use the `throwError` function mentioned above
668−and provide it with the appropriate value of type `ServantErr`, which is
668+and provide it with the appropriate value of type `ServerError`, which is
669669defined as:
670670
671671``` haskell ignore
672−data ServantErr = ServantErr
672+data ServerError = ServerError
673673 { errHTTPCode :: Int
674674 , errReasonPhrase :: String
675675 , errBody :: ByteString -- lazy bytestring
@@ -685,7 +685,7 @@ use record update syntax:
685685failingHandler :: Handler ()
686686failingHandler = throwError myerr
687687
688− where myerr :: ServantErr
688+ where myerr :: ServerError
689689 myerr = err503 { errBody = "Sorry dear user." }
690690```
691691
servant-client-core/src/Servant/Client/Core.hs+1−1
@@ -32,7 +32,7 @@ module Servant.Client.Core
3232 , AuthClientData
3333
3434 -- * Generic Client
35− , ServantError(..)
35+ , ClientError(..)
3636 , EmptyClient(..)
3737
3838 -- * Response
servant-client-core/src/Servant/Client/Core/ClientError.hs+5−5
@@ -9,7 +9,7 @@
99{-# LANGUAGE ScopedTypeVariables #-}
1010{-# LANGUAGE TypeFamilies #-}
1111module Servant.Client.Core.ClientError (
12− ServantError (..),
12+ ClientError (..),
1313 ) where
1414
1515import Prelude ()
@@ -42,7 +42,7 @@ import Servant.Client.Core.Response
4242-- | A type representing possible errors in a request
4343--
4444-- Note that this type substantially changed in 0.12.
45−data ServantError =
45+data ClientError =
4646 -- | The server returned an error response including the
4747 -- failing request. 'requestPath' includes the 'BaseUrl' and the
4848 -- path of the request.
@@ -57,7 +57,7 @@ data ServantError =
5757 | ConnectionError SomeException
5858 deriving (Show, Generic, Typeable)
5959
60−instance Eq ServantError where
60+instance Eq ClientError where
6161 FailureResponse req res == FailureResponse req' res' = req == req' && res == res'
6262 DecodeFailure t r == DecodeFailure t' r' = t == t' && r == r'
6363 UnsupportedContentType mt r == UnsupportedContentType mt' r' = mt == mt' && r == r'
@@ -74,11 +74,11 @@ instance Eq ServantError where
7474 InvalidContentTypeHeader {} == _ = False
7575 ConnectionError {} == _ = False
7676
77−instance Exception ServantError
77+instance Exception ClientError
7878
7979-- | Note: an exception in 'ConnectionError' might not be evaluated fully,
8080-- We only 'rnf' its 'show'ed value.
81−instance NFData ServantError where
81+instance NFData ClientError where
8282 rnf (FailureResponse req res) = rnf req `seq` rnf res
8383 rnf (DecodeFailure err res) = rnf err `seq` rnf res
8484 rnf (UnsupportedContentType mt' res) = mediaTypeRnf mt' `seq` rnf res
servant-client-core/src/Servant/Client/Core/HasClient.hs+4−4
@@ -254,7 +254,7 @@ instance {-# OVERLAPPING #-}
254254 , requestAccept = fromList $ toList accept
255255 }
256256 case mimeUnrender (Proxy :: Proxy ct) $ responseBody response of
257− Left err -> throwServantError $ DecodeFailure (pack err) response
257+ Left err -> throwClientError $ DecodeFailure (pack err) response
258258 Right val -> return $ Headers
259259 { getResponse = val
260260 , getHeadersHList = buildHeadersTo . toList $ responseHeaders response
@@ -662,7 +662,7 @@ checkContentTypeHeader response =
662662 case lookup "Content-Type" $ toList $ responseHeaders response of
663663 Nothing -> return $ "application"//"octet-stream"
664664 Just t -> case parseAccept t of
665− Nothing -> throwServantError $ InvalidContentTypeHeader response
665+ Nothing -> throwClientError $ InvalidContentTypeHeader response
666666 Just t' -> return t'
667667
668668decodedAs :: forall ct a m. (MimeUnrender ct a, RunClient m)
@@ -670,9 +670,9 @@ decodedAs :: forall ct a m. (MimeUnrender ct a, RunClient m)
670670decodedAs response ct = do
671671 responseContentType <- checkContentTypeHeader response
672672 unless (any (matches responseContentType) accept) $
673− throwServantError $ UnsupportedContentType responseContentType response
673+ throwClientError $ UnsupportedContentType responseContentType response
674674 case mimeUnrender ct $ responseBody response of
675− Left err -> throwServantError $ DecodeFailure (T.pack err) response
675+ Left err -> throwClientError $ DecodeFailure (T.pack err) response
676676 Right val -> return val
677677 where
678678 accept = toList $ contentTypes ct
servant-client-core/src/Servant/Client/Core/Reexport.hs+1−1
@@ -12,7 +12,7 @@ module Servant.Client.Core.Reexport
1212 , ResponseF(..)
1313
1414 -- * Data types
15− , ServantError(..)
15+ , ClientError(..)
1616 , EmptyClient(..)
1717
1818 -- * BaseUrl
servant-client-core/src/Servant/Client/Core/RunClient.hs+3−3
@@ -24,7 +24,7 @@ import Servant.Client.Core.Response
2424class Monad m => RunClient m where
2525 -- | How to make a request.
2626 runRequest :: Request -> m Response
27− throwServantError :: ServantError -> m a
27+ throwClientError :: ClientError -> m a
2828
2929class RunClient m => RunStreamingClient m where
3030 withStreamingRequest :: Request -> (StreamingResponse -> IO a) -> m a
@@ -38,9 +38,9 @@ class RunClient m => RunStreamingClient m where
3838-- Compare to 'RunClient'.
3939data ClientF a
4040 = RunRequest Request (Response -> a)
41− | Throw ServantError
41+ | Throw ClientError
4242 deriving (Functor)
4343
4444instance ClientF ~ f => RunClient (Free f) where
4545 runRequest req = liftF (RunRequest req id)
46− throwServantError = liftF . Throw
46+ throwClientError = liftF . Throw
servant-client-ghcjs/src/Servant/Client/Internal/XhrClient.hs+7−7
@@ -94,16 +94,16 @@ client api = api `clientIn` (Proxy :: Proxy ClientM)
9494--
9595-- NOTE: Does not support constant space streaming of the request body!
9696newtype ClientM a = ClientM
97− { runClientM' :: ReaderT ClientEnv (ExceptT ServantError IO) a }
97+ { runClientM' :: ReaderT ClientEnv (ExceptT ClientError IO) a }
9898 deriving ( Functor, Applicative, Monad, MonadIO, Generic
99− , MonadReader ClientEnv, MonadError ServantError, MonadThrow
99+ , MonadReader ClientEnv, MonadError ClientError, MonadThrow
100100 , MonadCatch)
101101
102102instance MonadBase IO ClientM where
103103 liftBase = ClientM . liftBase
104104
105105instance MonadBaseControl IO ClientM where
106− type StM ClientM a = Either ServantError a
106+ type StM ClientM a = Either ClientError a
107107
108108 liftBaseWith f = ClientM (liftBaseWith (\g -> f (g . runClientM')))
109109
@@ -121,12 +121,12 @@ instance Exception StreamingNotSupportedException where
121121
122122instance RunClient ClientM where
123123 runRequest = performRequest
124− throwServantError = throwError
124+ throwClientError = throwError
125125
126−runClientMOrigin :: ClientM a -> ClientEnv -> IO (Either ServantError a)
126+runClientMOrigin :: ClientM a -> ClientEnv -> IO (Either ClientError a)
127127runClientMOrigin cm env = runExceptT $ flip runReaderT env $ runClientM' cm
128128
129−runClientM :: ClientM a -> IO (Either ServantError a)
129+runClientM :: ClientM a -> IO (Either ClientError a)
130130runClientM m = do
131131 curLoc <- getWindowLocation
132132
@@ -298,7 +298,7 @@ foreign import javascript unsafe "$3.slice($1, $1 + $2)"
298298-- * inspecting the xhr response
299299
300300-- This function is only supposed to handle 'ConnectionError's. Other
301−-- 'ServantError's are created in Servant.Client.Req.
301+-- 'ClientError's are created in Servant.Client.Req.
302302toResponse :: JSXMLHttpRequest -> ClientM Response
303303toResponse xhr = do
304304 status <- liftIO $ getStatus xhr
servant-client/src/Servant/Client/Internal/HttpClient.hs+7−7
@@ -120,16 +120,16 @@ hoistClient = hoistClientMonad (Proxy :: Proxy ClientM)
120120-- | @ClientM@ is the monad in which client functions run. Contains the
121121-- 'Client.Manager' and 'BaseUrl' used for requests in the reader environment.
122122newtype ClientM a = ClientM
123− { unClientM :: ReaderT ClientEnv (ExceptT ServantError IO) a }
123+ { unClientM :: ReaderT ClientEnv (ExceptT ClientError IO) a }
124124 deriving ( Functor, Applicative, Monad, MonadIO, Generic
125− , MonadReader ClientEnv, MonadError ServantError, MonadThrow
125+ , MonadReader ClientEnv, MonadError ClientError, MonadThrow
126126 , MonadCatch)
127127
128128instance MonadBase IO ClientM where
129129 liftBase = ClientM . liftBase
130130
131131instance MonadBaseControl IO ClientM where
132− type StM ClientM a = Either ServantError a
132+ type StM ClientM a = Either ClientError a
133133
134134 liftBaseWith f = ClientM (liftBaseWith (\g -> f (g . unClientM)))
135135
@@ -141,9 +141,9 @@ instance Alt ClientM where
141141
142142instance RunClient ClientM where
143143 runRequest = performRequest
144− throwServantError = throwError
144+ throwClientError = throwError
145145
146−runClientM :: ClientM a -> ClientEnv -> IO (Either ServantError a)
146+runClientM :: ClientM a -> ClientEnv -> IO (Either ClientError a)
147147runClientM cm env = runExceptT $ flip runReaderT env $ unClientM cm
148148
149149performRequest :: Request -> ClientM Response
@@ -197,7 +197,7 @@ performRequest req = do
197197 fReq = Client.hrFinalRequest responses
198198 fRes = Client.hrFinalResponse responses
199199
200−mkFailureResponse :: BaseUrl -> Request -> ResponseF BSL.ByteString -> ServantError
200+mkFailureResponse :: BaseUrl -> Request -> ResponseF BSL.ByteString -> ClientError
201201mkFailureResponse burl request =
202202 FailureResponse (bimap (const ()) f request)
203203 where
@@ -270,7 +270,7 @@ requestToClientRequest burl r = Client.defaultRequest
270270 Http -> False
271271 Https -> True
272272
273−catchConnectionError :: IO a -> IO (Either ServantError a)
273+catchConnectionError :: IO a -> IO (Either ClientError a)
274274catchConnectionError action =
275275 catch (Right <$> action) $ \e ->
276276 pure . Left . ConnectionError $ SomeException (e :: Client.HttpException)
servant-client/src/Servant/Client/Internal/HttpClient/Streaming.hs+5−5
@@ -100,9 +100,9 @@ hoistClient = hoistClientMonad (Proxy :: Proxy ClientM)
100100-- | @ClientM@ is the monad in which client functions run. Contains the
101101-- 'Client.Manager' and 'BaseUrl' used for requests in the reader environment.
102102newtype ClientM a = ClientM
103− { unClientM :: ReaderT ClientEnv (ExceptT ServantError (Codensity IO)) a }
103+ { unClientM :: ReaderT ClientEnv (ExceptT ClientError (Codensity IO)) a }
104104 deriving ( Functor, Applicative, Monad, MonadIO, Generic
105− , MonadReader ClientEnv, MonadError ServantError)
105+ , MonadReader ClientEnv, MonadError ClientError)
106106
107107instance MonadBase IO ClientM where
108108 liftBase = ClientM . liftIO
@@ -113,12 +113,12 @@ instance Alt ClientM where
113113
114114instance RunClient ClientM where
115115 runRequest = performRequest
116− throwServantError = throwError
116+ throwClientError = throwError
117117
118118instance RunStreamingClient ClientM where
119119 withStreamingRequest = performWithStreamingRequest
120120
121−withClientM :: ClientM a -> ClientEnv -> (Either ServantError a -> IO b) -> IO b
121+withClientM :: ClientM a -> ClientEnv -> (Either ClientError a -> IO b) -> IO b
122122withClientM cm env k =
123123 let Codensity f = runExceptT $ flip runReaderT env $ unClientM cm
124124 in f k
@@ -133,7 +133,7 @@ withClientM cm env k =
133133-- /Note:/ we 'force' the result, so the likehood of accidentally leaking a
134134-- connection is smaller. Use with care.
135135--
136−runClientM :: NFData a => ClientM a -> ClientEnv -> IO (Either ServantError a)
136+runClientM :: NFData a => ClientM a -> ClientEnv -> IO (Either ClientError a)
137137runClientM cm env = withClientM cm env (evaluate . force)
138138
139139performRequest :: Request -> ClientM Response
servant-client/test/Servant/ClientSpec.hs+5−5
@@ -184,8 +184,8 @@ server = serve api (
184184 :<|> return
185185 :<|> (\ name -> case name of
186186 Just "alice" -> return alice
187− Just n -> throwError $ ServantErr 400 (n ++ " not found") "" []
188− Nothing -> throwError $ ServantErr 400 "missing parameter" "" [])
187+ Just n -> throwError $ ServerError 400 (n ++ " not found") "" []
188+ Nothing -> throwError $ ServerError 400 "missing parameter" "" [])
189189 :<|> (\ names -> return (zipWith Person names [0..]))
190190 :<|> return
191191 :<|> (Tagged $ \ _request respond -> respond $ Wai.responseLBS HTTP.ok200 [] "rawSuccess")
@@ -260,7 +260,7 @@ genAuthServer = serveWithContext genAuthAPI genAuthServerContext (const (return
260260manager' :: C.Manager
261261manager' = unsafePerformIO $ C.newManager C.defaultManagerSettings
262262
263−runClient :: ClientM a -> BaseUrl -> IO (Either ServantError a)
263+runClient :: ClientM a -> BaseUrl -> IO (Either ClientError a)
264264runClient x baseUrl' = runClientM x (mkClientEnv manager' baseUrl')
265265
266266sucessSpec :: Spec
@@ -352,7 +352,7 @@ sucessSpec = beforeAll (startWaiApp server) $ afterAll endWaiApp $ do
352352
353353wrappedApiSpec :: Spec
354354wrappedApiSpec = describe "error status codes" $ do
355− let serveW api = serve api $ throwError $ ServantErr 500 "error message" "" []
355+ let serveW api = serve api $ throwError $ ServerError 500 "error message" "" []
356356 context "are correctly handled by the client" $
357357 let test :: (WrappedApi, String) -> Spec
358358 test (WrappedApi api, desc) =
@@ -475,7 +475,7 @@ connectionErrorAPI :: Proxy ConnectionErrorAPI
475475connectionErrorAPI = Proxy
476476
477477connectionErrorSpec :: Spec
478−connectionErrorSpec = describe "Servant.Client.ServantError" $
478+connectionErrorSpec = describe "Servant.Client.ClientError" $
479479 it "correctly catches ConnectionErrors when the HTTP request can't go through" $ do
480480 let getInt = client connectionErrorAPI
481481 let baseUrl' = BaseUrl Http "example.invalid" 80 ""
servant-client/test/Servant/StreamSpec.hs+1−1
@@ -112,7 +112,7 @@ powerOfTwo = (2 ^)
112112manager' :: C.Manager
113113manager' = unsafePerformIO $ C.newManager C.defaultManagerSettings
114114
115−withClient :: ClientM a -> BaseUrl -> (Either ServantError a -> IO r) -> IO r
115+withClient :: ClientM a -> BaseUrl -> (Either ClientError a -> IO r) -> IO r
116116withClient x baseUrl' = withClientM x (mkClientEnv manager' baseUrl')
117117
118118testRunSourceIO :: SourceIO a
servant-http-streams/src/Servant/HttpStreams/Internal.hs+7−7
@@ -123,9 +123,9 @@ hoistClient = hoistClientMonad (Proxy :: Proxy ClientM)
123123-- | @ClientM@ is the monad in which client functions run. Contains the
124124-- 'Client.Manager' and 'BaseUrl' used for requests in the reader environment.
125125newtype ClientM a = ClientM
126− { unClientM :: ReaderT ClientEnv (ExceptT ServantError (Codensity IO)) a }
126+ { unClientM :: ReaderT ClientEnv (ExceptT ClientError (Codensity IO)) a }
127127 deriving ( Functor, Applicative, Monad, MonadIO, Generic
128− , MonadReader ClientEnv, MonadError ServantError)
128+ , MonadReader ClientEnv, MonadError ClientError)
129129
130130instance MonadBase IO ClientM where
131131 liftBase = ClientM . liftIO
@@ -136,15 +136,15 @@ instance Alt ClientM where
136136
137137instance RunClient ClientM where
138138 runRequest = performRequest
139− throwServantError = throwError
139+ throwClientError = throwError
140140
141141instance RunStreamingClient ClientM where
142142 withStreamingRequest = performWithStreamingRequest
143143
144−runClientM :: NFData a => ClientM a -> ClientEnv -> IO (Either ServantError a)
144+runClientM :: NFData a => ClientM a -> ClientEnv -> IO (Either ClientError a)
145145runClientM cm env = withClientM cm env (evaluate . force)
146146
147−withClientM :: ClientM a -> ClientEnv -> (Either ServantError a -> IO b) -> IO b
147+withClientM :: ClientM a -> ClientEnv -> (Either ClientError a -> IO b) -> IO b
148148withClientM cm env k =
149149 let Codensity f = runExceptT $ flip runReaderT env $ unClientM cm
150150 in f k
@@ -181,7 +181,7 @@ performWithStreamingRequest req k = do
181181 x <- k (clientResponseToResponse res' (fromInputStream body'))
182182 k1 x
183183
184−mkFailureResponse :: BaseUrl -> Request -> ResponseF BSL.ByteString -> ServantError
184+mkFailureResponse :: BaseUrl -> Request -> ResponseF BSL.ByteString -> ClientError
185185mkFailureResponse burl request =
186186 FailureResponse (bimap (const ()) f request)
187187 where
@@ -233,7 +233,7 @@ requestToClientRequest burl r = (request, body)
233233 Nothing -> (Client.emptyBody, Nothing)
234234 Just (body', typ) -> (convertBody body', Just (hContentType, renderHeader typ))
235235
236−catchConnectionError :: IO a -> IO (Either ServantError a)
236+catchConnectionError :: IO a -> IO (Either ClientError a)
237237catchConnectionError action =
238238 catch (Right <$> action) $ \e ->
239239 pure . Left . ConnectionError $ SomeException (e :: IOException)
servant-http-streams/test/Servant/ClientSpec.hs+6−6
@@ -182,8 +182,8 @@ server = serve api (
182182 :<|> return
183183 :<|> (\ name -> case name of
184184 Just "alice" -> return alice
185− Just n -> throwError $ ServantErr 400 (n ++ " not found") "" []
186− Nothing -> throwError $ ServantErr 400 "missing parameter" "" [])
185+ Just n -> throwError $ ServerError 400 (n ++ " not found") "" []
186+ Nothing -> throwError $ ServerError 400 "missing parameter" "" [])
187187 :<|> (\ names -> return (zipWith Person names [0..]))
188188 :<|> return
189189 :<|> (Tagged $ \ _request respond -> respond $ Wai.responseLBS HTTP.ok200 [] "rawSuccess")
@@ -254,10 +254,10 @@ genAuthServerContext = genAuthHandler :. EmptyContext
254254genAuthServer :: Application
255255genAuthServer = serveWithContext genAuthAPI genAuthServerContext (const (return alice))
256256
257−runClient :: NFData a => ClientM a -> BaseUrl -> IO (Either ServantError a)
257+runClient :: NFData a => ClientM a -> BaseUrl -> IO (Either ClientError a)
258258runClient x burl = withClientEnvIO burl (runClientM x)
259259
260−runClientUnsafe :: ClientM a -> BaseUrl -> IO (Either ServantError a)
260+runClientUnsafe :: ClientM a -> BaseUrl -> IO (Either ClientError a)
261261runClientUnsafe x burl = withClientEnvIO burl (runClientMUnsafe x)
262262 where
263263 runClientMUnsafe x env = withClientM x env return
@@ -343,7 +343,7 @@ sucessSpec = beforeAll (startWaiApp server) $ afterAll endWaiApp $ do
343343
344344wrappedApiSpec :: Spec
345345wrappedApiSpec = describe "error status codes" $ do
346− let serveW api = serve api $ throwError $ ServantErr 500 "error message" "" []
346+ let serveW api = serve api $ throwError $ ServerError 500 "error message" "" []
347347 context "are correctly handled by the client" $
348348 let test :: (WrappedApi, String) -> Spec
349349 test (WrappedApi api, desc) =
@@ -467,7 +467,7 @@ connectionErrorAPI :: Proxy ConnectionErrorAPI
467467connectionErrorAPI = Proxy
468468
469469connectionErrorSpec :: Spec
470−connectionErrorSpec = describe "Servant.Client.ServantError" $
470+connectionErrorSpec = describe "Servant.Client.ClientError" $
471471 xit "correctly catches ConnectionErrors when the HTTP request can't go through" $ do
472472 let getInt = client connectionErrorAPI
473473 let baseUrl' = BaseUrl Http "example.invalid" 80 ""
servant-http-streams/test/Servant/StreamSpec.hs+1−1
@@ -84,7 +84,7 @@ server = serve api
8484powerOfTwo :: Int -> Int
8585powerOfTwo = (2 ^)
8686
87−withClient :: ClientM a -> BaseUrl -> (Either ServantError a -> IO r) -> IO r
87+withClient :: ClientM a -> BaseUrl -> (Either ClientError a -> IO r) -> IO r
8888withClient x burl k = do
8989 withClientEnvIO burl $ \env -> withClientM x env k
9090
servant-server/servant-server.cabal+1−1
@@ -55,7 +55,7 @@ library
5555 Servant.Server.Internal.Handler
5656 Servant.Server.Internal.Router
5757 Servant.Server.Internal.RoutingApplication
58− Servant.Server.Internal.ServantErr
58+ Servant.Server.Internal.ServerError
5959 Servant.Server.StaticFiles
6060
6161 -- deprecated
servant-server/src/Servant/Server.hs+1−1
@@ -49,7 +49,7 @@ module Servant.Server
4949 -- , mkAuthHandler
5050
5151 -- * Default error type
52− , ServantErr(..)
52+ , ServerError(..)
5353 -- ** 3XX
5454 , err300
5555 , err301
servant-server/src/Servant/Server/Internal.hs+2−2
@@ -25,7 +25,7 @@ module Servant.Server.Internal
2525 , module Servant.Server.Internal.Handler
2626 , module Servant.Server.Internal.Router
2727 , module Servant.Server.Internal.RoutingApplication
28− , module Servant.Server.Internal.ServantErr
28+ , module Servant.Server.Internal.ServerError
2929 ) where
3030
3131import Control.Monad
@@ -91,7 +91,7 @@ import Servant.Server.Internal.Context
9191import Servant.Server.Internal.Handler
9292import Servant.Server.Internal.Router
9393import Servant.Server.Internal.RoutingApplication
94−import Servant.Server.Internal.ServantErr
94+import Servant.Server.Internal.ServerError
9595
9696#ifdef HAS_TYPE_ERROR
9797import GHC.TypeLits
servant-server/src/Servant/Server/Internal/BasicAuth.hs+1−1
@@ -27,7 +27,7 @@ import Network.Wai
2727import Servant.API.BasicAuth
2828 (BasicAuthData (BasicAuthData))
2929import Servant.Server.Internal.RoutingApplication
30−import Servant.Server.Internal.ServantErr
30+import Servant.Server.Internal.ServerError
3131
3232-- * Basic Auth
3333
servant-server/src/Servant/Server/Internal/Handler.hs+6−6
@@ -22,13 +22,13 @@ import Control.Monad.Trans.Except
2222 (ExceptT, runExceptT)
2323import GHC.Generics
2424 (Generic)
25−import Servant.Server.Internal.ServantErr
26− (ServantErr)
25+import Servant.Server.Internal.ServerError
26+ (ServerError)
2727
28−newtype Handler a = Handler { runHandler' :: ExceptT ServantErr IO a }
28+newtype Handler a = Handler { runHandler' :: ExceptT ServerError IO a }
2929 deriving
3030 ( Functor, Applicative, Monad, MonadIO, Generic
31− , MonadError ServantErr
31+ , MonadError ServerError
3232 , MonadThrow, MonadCatch, MonadMask
3333 )
3434
@@ -36,7 +36,7 @@ instance MonadBase IO Handler where
3636 liftBase = Handler . liftBase
3737
3838instance MonadBaseControl IO Handler where
39− type StM Handler a = Either ServantErr a
39+ type StM Handler a = Either ServerError a
4040
4141 -- liftBaseWith :: (RunInBase Handler IO -> IO a) -> Handler a
4242 liftBaseWith f = Handler (liftBaseWith (\g -> f (g . runHandler')))
@@ -44,5 +44,5 @@ instance MonadBaseControl IO Handler where
4444 -- restoreM :: StM Handler a -> Handler a
4545 restoreM st = Handler (restoreM st)
4646
47−runHandler :: Handler a -> IO (Either ServantErr a)
47+runHandler :: Handler a -> IO (Either ServerError a)
4848runHandler = runExceptT . runHandler'
servant-server/src/Servant/Server/Internal/Router.hs+1−1
@@ -18,7 +18,7 @@ import qualified Data.Text as T
1818import Network.Wai
1919 (Response, pathInfo)
2020import Servant.Server.Internal.RoutingApplication
21−import Servant.Server.Internal.ServantErr
21+import Servant.Server.Internal.ServerError
2222
2323type Router env = Router' env RoutingApplication
2424
servant-server/src/Servant/Server/Internal/RoutingApplication.hs+8−8
@@ -31,7 +31,7 @@ import Network.Wai
3131import Prelude ()
3232import Prelude.Compat
3333import Servant.Server.Internal.Handler
34−import Servant.Server.Internal.ServantErr
34+import Servant.Server.Internal.ServerError
3535
3636type RoutingApplication =
3737 Request -- ^ the request, the field 'pathInfo' may be modified by url routing
@@ -39,9 +39,9 @@ type RoutingApplication =
3939
4040-- | The result of matching against a path in the route tree.
4141data RouteResult a =
42− Fail ServantErr -- ^ Keep trying other paths. The @ServantErr@
42+ Fail ServerError -- ^ Keep trying other paths. The @ServantErr@
4343 -- should only be 404, 405 or 406.
44− | FailFatal !ServantErr -- ^ Don't try other paths.
44+ | FailFatal !ServerError -- ^ Don't try other paths.
4545 | Route !a
4646 deriving (Eq, Show, Read, Functor)
4747
@@ -97,8 +97,8 @@ toApplication :: RoutingApplication -> Application
9797toApplication ra request respond = ra request routingRespond
9898 where
9999 routingRespond :: RouteResult Response -> IO ResponseReceived
100− routingRespond (Fail err) = respond $ responseServantErr err
101− routingRespond (FailFatal err) = respond $ responseServantErr err
100+ routingRespond (Fail err) = respond $ responseServerError err
101+ routingRespond (FailFatal err) = respond $ responseServerError err
102102 routingRespond (Route v) = respond v
103103
104104-- | A 'Delayed' is a representation of a handler with scheduled
@@ -235,11 +235,11 @@ emptyDelayed result =
235235 r = return ()
236236
237237-- | Fail with the option to recover.
238−delayedFail :: ServantErr -> DelayedIO a
238+delayedFail :: ServerError -> DelayedIO a
239239delayedFail err = liftRouteResult $ Fail err
240240
241241-- | Fail fatally, i.e., without any option to recover.
242−delayedFailFatal :: ServantErr -> DelayedIO a
242+delayedFailFatal :: ServerError -> DelayedIO a
243243delayedFailFatal err = liftRouteResult $ FailFatal err
244244
245245-- | Gain access to the incoming request.
@@ -388,7 +388,7 @@ runAction action env req respond k = runResourceT $
388388 go (Route a) = liftIO $ do
389389 e <- runHandler a
390390 case e of
391− Left err -> return . Route $ responseServantErr err
391+ Left err -> return . Route $ responseServerError err
392392 Right x -> return $! k x
393393
394394{- Note [Existential Record Update]
servant-server/src/Servant/Server/Internal/ServantErr.hs → servant-server/src/Servant/Server/Internal/ServerError.hsrenamed+75−73
@@ -1,7 +1,7 @@
11{-# LANGUAGE DeriveDataTypeable #-}
22{-# LANGUAGE OverloadedStrings #-}
33{-# LANGUAGE RecordWildCards #-}
4−module Servant.Server.Internal.ServantErr where
4+module Servant.Server.Internal.ServerError where
55
66import Control.Exception
77 (Exception)
@@ -13,16 +13,18 @@ import qualified Network.HTTP.Types as HTTP
1313import Network.Wai
1414 (Response, responseLBS)
1515
16−data ServantErr = ServantErr { errHTTPCode :: Int
17− , errReasonPhrase :: String
18− , errBody :: LBS.ByteString
19− , errHeaders :: [HTTP.Header]
20− } deriving (Show, Eq, Read, Typeable)
16+data ServerError = ServerError
17+ { errHTTPCode :: Int
18+ , errReasonPhrase :: String
19+ , errBody :: LBS.ByteString
20+ , errHeaders :: [HTTP.Header]
21+ }
22+ deriving (Show, Eq, Read, Typeable)
2123
22−instance Exception ServantErr
24+instance Exception ServerError
2325
24−responseServantErr :: ServantErr -> Response
25−responseServantErr ServantErr{..} = responseLBS status errHeaders errBody
26+responseServerError :: ServerError -> Response
27+responseServerError ServerError{..} = responseLBS status errHeaders errBody
2628 where
2729 status = HTTP.mkStatus errHTTPCode (BS.pack errReasonPhrase)
2830
@@ -33,8 +35,8 @@ responseServantErr ServantErr{..} = responseLBS status errHeaders errBody
3335-- > failingHandler :: Handler ()
3436-- > failingHandler = throwError $ err300 { errBody = "I can't choose." }
3537--
36−err300 :: ServantErr
37−err300 = ServantErr { errHTTPCode = 300
38+err300 :: ServerError
39+err300 = ServerError { errHTTPCode = 300
3840 , errReasonPhrase = "Multiple Choices"
3941 , errBody = ""
4042 , errHeaders = []
@@ -47,8 +49,8 @@ err300 = ServantErr { errHTTPCode = 300
4749-- > failingHandler :: Handler ()
4850-- > failingHandler = throwError err301
4951--
50−err301 :: ServantErr
51−err301 = ServantErr { errHTTPCode = 301
52+err301 :: ServerError
53+err301 = ServerError { errHTTPCode = 301
5254 , errReasonPhrase = "Moved Permanently"
5355 , errBody = ""
5456 , errHeaders = []
@@ -61,8 +63,8 @@ err301 = ServantErr { errHTTPCode = 301
6163-- > failingHandler :: Handler ()
6264-- > failingHandler = throwError err302
6365--
64−err302 :: ServantErr
65−err302 = ServantErr { errHTTPCode = 302
66+err302 :: ServerError
67+err302 = ServerError { errHTTPCode = 302
6668 , errReasonPhrase = "Found"
6769 , errBody = ""
6870 , errHeaders = []
@@ -75,8 +77,8 @@ err302 = ServantErr { errHTTPCode = 302
7577-- > failingHandler :: Handler ()
7678-- > failingHandler = throwError err303
7779--
78−err303 :: ServantErr
79−err303 = ServantErr { errHTTPCode = 303
80+err303 :: ServerError
81+err303 = ServerError { errHTTPCode = 303
8082 , errReasonPhrase = "See Other"
8183 , errBody = ""
8284 , errHeaders = []
@@ -89,8 +91,8 @@ err303 = ServantErr { errHTTPCode = 303
8991-- > failingHandler :: Handler ()
9092-- > failingHandler = throwError err304
9193--
92−err304 :: ServantErr
93−err304 = ServantErr { errHTTPCode = 304
94+err304 :: ServerError
95+err304 = ServerError { errHTTPCode = 304
9496 , errReasonPhrase = "Not Modified"
9597 , errBody = ""
9698 , errHeaders = []
@@ -103,8 +105,8 @@ err304 = ServantErr { errHTTPCode = 304
103105-- > failingHandler :: Handler ()
104106-- > failingHandler = throwError err305
105107--
106−err305 :: ServantErr
107−err305 = ServantErr { errHTTPCode = 305
108+err305 :: ServerError
109+err305 = ServerError { errHTTPCode = 305
108110 , errReasonPhrase = "Use Proxy"
109111 , errBody = ""
110112 , errHeaders = []
@@ -117,8 +119,8 @@ err305 = ServantErr { errHTTPCode = 305
117119-- > failingHandler :: Handler ()
118120-- > failingHandler = throwError err307
119121--
120−err307 :: ServantErr
121−err307 = ServantErr { errHTTPCode = 307
122+err307 :: ServerError
123+err307 = ServerError { errHTTPCode = 307
122124 , errReasonPhrase = "Temporary Redirect"
123125 , errBody = ""
124126 , errHeaders = []
@@ -131,8 +133,8 @@ err307 = ServantErr { errHTTPCode = 307
131133-- > failingHandler :: Handler ()
132134-- > failingHandler = throwError $ err400 { errBody = "Your request makes no sense to me." }
133135--
134−err400 :: ServantErr
135−err400 = ServantErr { errHTTPCode = 400
136+err400 :: ServerError
137+err400 = ServerError { errHTTPCode = 400
136138 , errReasonPhrase = "Bad Request"
137139 , errBody = ""
138140 , errHeaders = []
@@ -145,8 +147,8 @@ err400 = ServantErr { errHTTPCode = 400
145147-- > failingHandler :: Handler ()
146148-- > failingHandler = throwError $ err401 { errBody = "Your credentials are invalid." }
147149--
148−err401 :: ServantErr
149−err401 = ServantErr { errHTTPCode = 401
150+err401 :: ServerError
151+err401 = ServerError { errHTTPCode = 401
150152 , errReasonPhrase = "Unauthorized"
151153 , errBody = ""
152154 , errHeaders = []
@@ -159,8 +161,8 @@ err401 = ServantErr { errHTTPCode = 401
159161-- > failingHandler :: Handler ()
160162-- > failingHandler = throwError $ err402 { errBody = "You have 0 credits. Please give me $$$." }
161163--
162−err402 :: ServantErr
163−err402 = ServantErr { errHTTPCode = 402
164+err402 :: ServerError
165+err402 = ServerError { errHTTPCode = 402
164166 , errReasonPhrase = "Payment Required"
165167 , errBody = ""
166168 , errHeaders = []
@@ -173,8 +175,8 @@ err402 = ServantErr { errHTTPCode = 402
173175-- > failingHandler :: Handler ()
174176-- > failingHandler = throwError $ err403 { errBody = "Please login first." }
175177--
176−err403 :: ServantErr
177−err403 = ServantErr { errHTTPCode = 403
178+err403 :: ServerError
179+err403 = ServerError { errHTTPCode = 403
178180 , errReasonPhrase = "Forbidden"
179181 , errBody = ""
180182 , errHeaders = []
@@ -187,8 +189,8 @@ err403 = ServantErr { errHTTPCode = 403
187189-- > failingHandler :: Handler ()
188190-- > failingHandler = throwError $ err404 { errBody = "(╯°□°)╯︵ ┻━┻)." }
189191--
190−err404 :: ServantErr
191−err404 = ServantErr { errHTTPCode = 404
192+err404 :: ServerError
193+err404 = ServerError { errHTTPCode = 404
192194 , errReasonPhrase = "Not Found"
193195 , errBody = ""
194196 , errHeaders = []
@@ -201,8 +203,8 @@ err404 = ServantErr { errHTTPCode = 404
201203-- > failingHandler :: Handler ()
202204-- > failingHandler = throwError $ err405 { errBody = "Your account privileges does not allow for this. Please pay $$$." }
203205--
204−err405 :: ServantErr
205−err405 = ServantErr { errHTTPCode = 405
206+err405 :: ServerError
207+err405 = ServerError { errHTTPCode = 405
206208 , errReasonPhrase = "Method Not Allowed"
207209 , errBody = ""
208210 , errHeaders = []
@@ -215,8 +217,8 @@ err405 = ServantErr { errHTTPCode = 405
215217-- > failingHandler :: Handler ()
216218-- > failingHandler = throwError err406
217219--
218−err406 :: ServantErr
219−err406 = ServantErr { errHTTPCode = 406
220+err406 :: ServerError
221+err406 = ServerError { errHTTPCode = 406
220222 , errReasonPhrase = "Not Acceptable"
221223 , errBody = ""
222224 , errHeaders = []
@@ -229,8 +231,8 @@ err406 = ServantErr { errHTTPCode = 406
229231-- > failingHandler :: Handler ()
230232-- > failingHandler = throwError err407
231233--
232−err407 :: ServantErr
233−err407 = ServantErr { errHTTPCode = 407
234+err407 :: ServerError
235+err407 = ServerError { errHTTPCode = 407
234236 , errReasonPhrase = "Proxy Authentication Required"
235237 , errBody = ""
236238 , errHeaders = []
@@ -243,8 +245,8 @@ err407 = ServantErr { errHTTPCode = 407
243245-- > failingHandler :: Handler ()
244246-- > failingHandler = throwError $ err409 { errBody = "Transaction conflicts with 59879cb56c7c159231eeacdd503d755f7e835f74" }
245247--
246−err409 :: ServantErr
247−err409 = ServantErr { errHTTPCode = 409
248+err409 :: ServerError
249+err409 = ServerError { errHTTPCode = 409
248250 , errReasonPhrase = "Conflict"
249251 , errBody = ""
250252 , errHeaders = []
@@ -257,8 +259,8 @@ err409 = ServantErr { errHTTPCode = 409
257259-- > failingHandler :: Handler ()
258260-- > failingHandler = throwError $ err410 { errBody = "I know it was here at some point, but.. I blame bad luck." }
259261--
260−err410 :: ServantErr
261−err410 = ServantErr { errHTTPCode = 410
262+err410 :: ServerError
263+err410 = ServerError { errHTTPCode = 410
262264 , errReasonPhrase = "Gone"
263265 , errBody = ""
264266 , errHeaders = []
@@ -271,8 +273,8 @@ err410 = ServantErr { errHTTPCode = 410
271273-- > failingHandler :: Handler ()
272274-- > failingHandler = throwError err411
273275--
274−err411 :: ServantErr
275−err411 = ServantErr { errHTTPCode = 411
276+err411 :: ServerError
277+err411 = ServerError { errHTTPCode = 411
276278 , errReasonPhrase = "Length Required"
277279 , errBody = ""
278280 , errHeaders = []
@@ -285,8 +287,8 @@ err411 = ServantErr { errHTTPCode = 411
285287-- > failingHandler :: Handler ()
286288-- > failingHandler = throwError $ err412 { errBody = "Precondition fail: x < 42 && y > 57" }
287289--
288−err412 :: ServantErr
289−err412 = ServantErr { errHTTPCode = 412
290+err412 :: ServerError
291+err412 = ServerError { errHTTPCode = 412
290292 , errReasonPhrase = "Precondition Failed"
291293 , errBody = ""
292294 , errHeaders = []
@@ -299,8 +301,8 @@ err412 = ServantErr { errHTTPCode = 412
299301-- > failingHandler :: Handler ()
300302-- > failingHandler = throwError $ err413 { errBody = "Request exceeded 64k." }
301303--
302−err413 :: ServantErr
303−err413 = ServantErr { errHTTPCode = 413
304+err413 :: ServerError
305+err413 = ServerError { errHTTPCode = 413
304306 , errReasonPhrase = "Request Entity Too Large"
305307 , errBody = ""
306308 , errHeaders = []
@@ -313,8 +315,8 @@ err413 = ServantErr { errHTTPCode = 413
313315-- > failingHandler :: Handler ()
314316-- > failingHandler = throwError $ err414 { errBody = "Maximum length is 64." }
315317--
316−err414 :: ServantErr
317−err414 = ServantErr { errHTTPCode = 414
318+err414 :: ServerError
319+err414 = ServerError { errHTTPCode = 414
318320 , errReasonPhrase = "Request-URI Too Large"
319321 , errBody = ""
320322 , errHeaders = []
@@ -327,8 +329,8 @@ err414 = ServantErr { errHTTPCode = 414
327329-- > failingHandler :: Handler ()
328330-- > failingHandler = throwError $ err415 { errBody = "Supported media types: gif, png" }
329331--
330−err415 :: ServantErr
331−err415 = ServantErr { errHTTPCode = 415
332+err415 :: ServerError
333+err415 = ServerError { errHTTPCode = 415
332334 , errReasonPhrase = "Unsupported Media Type"
333335 , errBody = ""
334336 , errHeaders = []
@@ -341,8 +343,8 @@ err415 = ServantErr { errHTTPCode = 415
341343-- > failingHandler :: Handler ()
342344-- > failingHandler = throwError $ err416 { errBody = "Valid range is [0, 424242]." }
343345--
344−err416 :: ServantErr
345−err416 = ServantErr { errHTTPCode = 416
346+err416 :: ServerError
347+err416 = ServerError { errHTTPCode = 416
346348 , errReasonPhrase = "Request range not satisfiable"
347349 , errBody = ""
348350 , errHeaders = []
@@ -355,8 +357,8 @@ err416 = ServantErr { errHTTPCode = 416
355357-- > failingHandler :: Handler ()
356358-- > failingHandler = throwError $ err417 { errBody = "I found a quux in the request. This isn't going to work." }
357359--
358−err417 :: ServantErr
359−err417 = ServantErr { errHTTPCode = 417
360+err417 :: ServerError
361+err417 = ServerError { errHTTPCode = 417
360362 , errReasonPhrase = "Expectation Failed"
361363 , errBody = ""
362364 , errHeaders = []
@@ -369,8 +371,8 @@ err417 = ServantErr { errHTTPCode = 417
369371-- > failingHandler :: Handler ()
370372-- > failingHandler = throwError $ err418 { errBody = "Apologies, this is not a webserver but a teapot." }
371373--
372−err418 :: ServantErr
373−err418 = ServantErr { errHTTPCode = 418
374+err418 :: ServerError
375+err418 = ServerError { errHTTPCode = 418
374376 , errReasonPhrase = "I'm a teapot"
375377 , errBody = ""
376378 , errHeaders = []
@@ -383,8 +385,8 @@ err418 = ServantErr { errHTTPCode = 418
383385-- > failingHandler :: Handler ()
384386-- > failingHandler = throwError $ err422 { errBody = "I understood your request, but can't process it." }
385387--
386−err422 :: ServantErr
387−err422 = ServantErr { errHTTPCode = 422
388+err422 :: ServerError
389+err422 = ServerError { errHTTPCode = 422
388390 , errReasonPhrase = "Unprocessable Entity"
389391 , errBody = ""
390392 , errHeaders = []
@@ -397,8 +399,8 @@ err422 = ServantErr { errHTTPCode = 422
397399-- > failingHandler :: Handler ()
398400-- > failingHandler = throwError $ err500 { errBody = "Exception in module A.B.C:55. Have a great day!" }
399401--
400−err500 :: ServantErr
401−err500 = ServantErr { errHTTPCode = 500
402+err500 :: ServerError
403+err500 = ServerError { errHTTPCode = 500
402404 , errReasonPhrase = "Internal Server Error"
403405 , errBody = ""
404406 , errHeaders = []
@@ -411,8 +413,8 @@ err500 = ServantErr { errHTTPCode = 500
411413-- > failingHandler :: Handler ()
412414-- > failingHandler = throwError $ err501 { errBody = "/v1/foo is not supported with quux in the request." }
413415--
414−err501 :: ServantErr
415−err501 = ServantErr { errHTTPCode = 501
416+err501 :: ServerError
417+err501 = ServerError { errHTTPCode = 501
416418 , errReasonPhrase = "Not Implemented"
417419 , errBody = ""
418420 , errHeaders = []
@@ -425,8 +427,8 @@ err501 = ServantErr { errHTTPCode = 501
425427-- > failingHandler :: Handler ()
426428-- > failingHandler = throwError $ err502 { errBody = "Tried gateway foo, bar, and baz. None responded." }
427429--
428−err502 :: ServantErr
429−err502 = ServantErr { errHTTPCode = 502
430+err502 :: ServerError
431+err502 = ServerError { errHTTPCode = 502
430432 , errReasonPhrase = "Bad Gateway"
431433 , errBody = ""
432434 , errHeaders = []
@@ -439,8 +441,8 @@ err502 = ServantErr { errHTTPCode = 502
439441-- > failingHandler :: Handler ()
440442-- > failingHandler = throwError $ err503 { errBody = "We're rewriting in PHP." }
441443--
442−err503 :: ServantErr
443−err503 = ServantErr { errHTTPCode = 503
444+err503 :: ServerError
445+err503 = ServerError { errHTTPCode = 503
444446 , errReasonPhrase = "Service Unavailable"
445447 , errBody = ""
446448 , errHeaders = []
@@ -453,8 +455,8 @@ err503 = ServantErr { errHTTPCode = 503
453455-- > failingHandler :: Handler ()
454456-- > failingHandler = throwError $ err504 { errBody = "Backend foobar did not respond in 5 seconds." }
455457--
456−err504 :: ServantErr
457−err504 = ServantErr { errHTTPCode = 504
458+err504 :: ServerError
459+err504 = ServerError { errHTTPCode = 504
458460 , errReasonPhrase = "Gateway Time-out"
459461 , errBody = ""
460462 , errHeaders = []
@@ -467,8 +469,8 @@ err504 = ServantErr { errHTTPCode = 504
467469-- > failingHandler :: Handler ()
468470-- > failingHandler = throwError $ err505 { errBody = "I support HTTP/4.0 only." }
469471--
470−err505 :: ServantErr
471−err505 = ServantErr { errHTTPCode = 505
472+err505 :: ServerError
473+err505 = ServerError { errHTTPCode = 505
472474 , errReasonPhrase = "HTTP Version not supported"
473475 , errBody = ""
474476 , errHeaders = []