git.iko.soy/typeable/servant
on master help sign in
Rename ServantError to ClientError, ServantErr to ServerError
a5655f8Oleg Grenrus
.travis.yml+3−9
@@ -87,9 +87,7 @@ install:
87 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"doc/cookbook/db-sqlite-simple\"\\n' >> cabal.project ; fi"
87 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"doc/cookbook/db-sqlite-simple\"\\n' >> cabal.project ; fi"
88 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"doc/cookbook/file-upload\"\\n' >> cabal.project ; fi"
88 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"doc/cookbook/file-upload\"\\n' >> cabal.project ; fi"
89 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"doc/cookbook/generic\"\\n' >> cabal.project ; fi"
89 - "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"
91 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"doc/cookbook/https\"\\n' >> cabal.project ; fi"
90 - "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"
93 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"doc/cookbook/testing\"\\n' >> cabal.project ; fi"
91 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"doc/cookbook/testing\"\\n' >> cabal.project ; fi"
94 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"doc/cookbook/structuring-apis\"\\n' >> cabal.project ; fi"
92 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"doc/cookbook/structuring-apis\"\\n' >> cabal.project ; fi"
95 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"doc/cookbook/using-custom-monad\"\\n' >> cabal.project ; fi"
93 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"doc/cookbook/using-custom-monad\"\\n' >> cabal.project ; fi"
@@ -106,7 +104,7 @@ install:
106 - "echo 'reorder-goals: True' >> cabal.project"
104 - "echo 'reorder-goals: True' >> cabal.project"
107 - "echo 'optimization: False' >> cabal.project "
105 - "echo 'optimization: False' >> cabal.project "
108 - touch cabal.project.local
106 - 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"
110 - cat cabal.project || true
108 - cat cabal.project || true
111 - cat cabal.project.local || true
109 - cat cabal.project.local || true
112 - if [ -f "servant/configure.ac" ]; then (cd "servant" && autoreconf -i); fi
110 - if [ -f "servant/configure.ac" ]; then (cd "servant" && autoreconf -i); fi
@@ -127,15 +125,13 @@ install:
127 - if [ -f "doc/cookbook/db-sqlite-simple/configure.ac" ]; then (cd "doc/cookbook/db-sqlite-simple" && autoreconf -i); fi
125 - if [ -f "doc/cookbook/db-sqlite-simple/configure.ac" ]; then (cd "doc/cookbook/db-sqlite-simple" && autoreconf -i); fi
128 - if [ -f "doc/cookbook/file-upload/configure.ac" ]; then (cd "doc/cookbook/file-upload" && autoreconf -i); fi
126 - if [ -f "doc/cookbook/file-upload/configure.ac" ]; then (cd "doc/cookbook/file-upload" && autoreconf -i); fi
129 - if [ -f "doc/cookbook/generic/configure.ac" ]; then (cd "doc/cookbook/generic" && autoreconf -i); fi
127 - 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
131 - if [ -f "doc/cookbook/https/configure.ac" ]; then (cd "doc/cookbook/https" && autoreconf -i); fi
128 - 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
133 - if [ -f "doc/cookbook/testing/configure.ac" ]; then (cd "doc/cookbook/testing" && autoreconf -i); fi
129 - if [ -f "doc/cookbook/testing/configure.ac" ]; then (cd "doc/cookbook/testing" && autoreconf -i); fi
134 - if [ -f "doc/cookbook/structuring-apis/configure.ac" ]; then (cd "doc/cookbook/structuring-apis" && autoreconf -i); fi
130 - if [ -f "doc/cookbook/structuring-apis/configure.ac" ]; then (cd "doc/cookbook/structuring-apis" && autoreconf -i); fi
135 - if [ -f "doc/cookbook/using-custom-monad/configure.ac" ]; then (cd "doc/cookbook/using-custom-monad" && autoreconf -i); fi
131 - if [ -f "doc/cookbook/using-custom-monad/configure.ac" ]; then (cd "doc/cookbook/using-custom-monad" && autoreconf -i); fi
136 - if [ -f "doc/cookbook/using-free-client/configure.ac" ]; then (cd "doc/cookbook/using-free-client" && autoreconf -i); fi
132 - if [ -f "doc/cookbook/using-free-client/configure.ac" ]; then (cd "doc/cookbook/using-free-client" && autoreconf -i); fi
137 - rm -f cabal.project.freeze
133 - 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
139 - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
135 - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
140
136
141# Here starts the actual work to be performed for the package under test;
137# Here starts the actual work to be performed for the package under test;
@@ -169,9 +165,7 @@ script:
169 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"cookbook-db-sqlite-simple-*/*.cabal\"\\n' >> cabal.project ; fi"
165 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"cookbook-db-sqlite-simple-*/*.cabal\"\\n' >> cabal.project ; fi"
170 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"cookbook-file-upload-*/*.cabal\"\\n' >> cabal.project ; fi"
166 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"cookbook-file-upload-*/*.cabal\"\\n' >> cabal.project ; fi"
171 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"cookbook-generic-*/*.cabal\"\\n' >> cabal.project ; fi"
167 - "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"
173 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"cookbook-https-*/*.cabal\"\\n' >> cabal.project ; fi"
168 - "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"
175 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"cookbook-testing-*/*.cabal\"\\n' >> cabal.project ; fi"
169 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"cookbook-testing-*/*.cabal\"\\n' >> cabal.project ; fi"
176 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"cookbook-structuring-apis-*/*.cabal\"\\n' >> cabal.project ; fi"
170 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"cookbook-structuring-apis-*/*.cabal\"\\n' >> cabal.project ; fi"
177 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"cookbook-using-custom-monad-*/*.cabal\"\\n' >> cabal.project ; fi"
171 - "if [ $HCNUMVER -eq 80404 ] || [ $HCNUMVER -eq 80603 ] ; then printf 'packages: \"cookbook-using-custom-monad-*/*.cabal\"\\n' >> cabal.project ; fi"
@@ -188,7 +182,7 @@ script:
188 - "echo 'reorder-goals: True' >> cabal.project"
182 - "echo 'reorder-goals: True' >> cabal.project"
189 - "echo 'optimization: False' >> cabal.project "
183 - "echo 'optimization: False' >> cabal.project "
190 - touch cabal.project.local
184 - 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"
192 - cat cabal.project || true
186 - cat cabal.project || true
193 - cat cabal.project.local || true
187 - cat cabal.project.local || true
194 - echo -en 'travis_fold:end:unpack\\r'
188 - echo -en 'travis_fold:end:unpack\\r'
cabal.project+3−3
@@ -21,11 +21,11 @@ packages:
21 doc/cookbook/db-sqlite-simple
21 doc/cookbook/db-sqlite-simple
22 doc/cookbook/file-upload
22 doc/cookbook/file-upload
23 doc/cookbook/generic
23 doc/cookbook/generic
24− doc/cookbook/hoist-server-with-context
24+ -- doc/cookbook/hoist-server-with-context
25 doc/cookbook/https
25 doc/cookbook/https
26− doc/cookbook/jwt-and-basic-auth/
26+ -- doc/cookbook/jwt-and-basic-auth/
27 -- doc/cookbook/pagination
27 -- doc/cookbook/pagination
28− -- doc/cookbook/sentry
28+ -- doc/cookbook/sentry
29 doc/cookbook/testing
29 doc/cookbook/testing
30 doc/cookbook/structuring-apis
30 doc/cookbook/structuring-apis
31 doc/cookbook/using-custom-monad
31 doc/cookbook/using-custom-monad
doc/cookbook/testing/Testing.lhs+2−2
@@ -234,7 +234,7 @@ clientEnv esHost esPort = do
234 manager <- newManager defaultManagerSettings
234 manager <- newManager defaultManagerSettings
235 pure $ mkClientEnv manager baseUrl
235 pure $ mkClientEnv manager baseUrl
236
236
237−runSearchClient :: Text -> Text -> ClientM a -> IO (Either ServantError a)
237+runSearchClient :: Text -> Text -> ClientM a -> IO (Either ClientError a)
238runSearchClient esHost esPort = (clientEnv esHost esPort >>=) . runClientM
238runSearchClient esHost esPort = (clientEnv esHost esPort >>=) . runClientM
239```
239```
240
240
@@ -267,7 +267,7 @@ docServer esHost esPort = getDocById esHost esPort
267-- actions
267-- actions
268getDocById :: Text -> Text -> Integer -> Handler Value
268getDocById :: Text -> Text -> Integer -> Handler Value
269getDocById esHost esPort docId = do
269getDocById esHost esPort docId = do
270− -- Our Servant Client function returns Either ServantError Value here:
270+ -- Our Servant Client function returns Either ClientError Value here:
271 docRes <- liftIO $ runSearchClient esHost esPort (getDocument docId)
271 docRes <- liftIO $ runSearchClient esHost esPort (getDocument docId)
272 case docRes of
272 case docRes of
273 Left err -> throwError $ err404 { errBody = "Failed looking up content" }
273 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
599
599
600## The `Handler` monad
600## The `Handler` monad
601
601
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`
603([haddock documentation for `ExceptT`](http://hackage.haskell.org/package/mtl-2.2.1/docs/Control-Monad-Except.html#t:ExceptT)).
603([haddock documentation for `ExceptT`](http://hackage.haskell.org/package/mtl-2.2.1/docs/Control-Monad-Except.html#t:ExceptT)).
604One might wonder: why this monad? The answer is that it is the
604One might wonder: why this monad? The answer is that it is the
605simplest monad with the following properties:
605simplest monad with the following properties:
@@ -617,7 +617,7 @@ newtype ExceptT e m a = ExceptT (m (Either e a))
617```
617```
618
618
619In short, this means that a handler of type `Handler a` is simply
619In 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
621action that either returns an error or a result.
621action that either returns an error or a result.
622
622
623The module [`Control.Monad.Except`](https://hackage.haskell.org/package/mtl-2.2.1/docs/Control-Monad-Except.html#t:ExceptT)
623The 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
660 return (FileContent filecontent)
660 return (FileContent filecontent)
661```
661```
662
662
663−### Failing, through `ServantErr`
663+### Failing, through `ServerError`
664
664
665If you want to explicitly fail at providing the result promised by an endpoint
665If you want to explicitly fail at providing the result promised by an endpoint
666using the appropriate HTTP status code (not found, unauthorized, etc) and some
666using the appropriate HTTP status code (not found, unauthorized, etc) and some
667error message, all you have to do is use the `throwError` function mentioned above
667error 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
669defined as:
669defined as:
670
670
671``` haskell ignore
671``` haskell ignore
672−data ServantErr = ServantErr
672+data ServerError = ServerError
673 { errHTTPCode :: Int
673 { errHTTPCode :: Int
674 , errReasonPhrase :: String
674 , errReasonPhrase :: String
675 , errBody :: ByteString -- lazy bytestring
675 , errBody :: ByteString -- lazy bytestring
@@ -685,7 +685,7 @@ use record update syntax:
685failingHandler :: Handler ()
685failingHandler :: Handler ()
686failingHandler = throwError myerr
686failingHandler = throwError myerr
687
687
688− where myerr :: ServantErr
688+ where myerr :: ServerError
689 myerr = err503 { errBody = "Sorry dear user." }
689 myerr = err503 { errBody = "Sorry dear user." }
690```
690```
691
691
servant-client-core/src/Servant/Client/Core.hs+1−1
@@ -32,7 +32,7 @@ module Servant.Client.Core
32 , AuthClientData
32 , AuthClientData
33
33
34 -- * Generic Client
34 -- * Generic Client
35− , ServantError(..)
35+ , ClientError(..)
36 , EmptyClient(..)
36 , EmptyClient(..)
37
37
38 -- * Response
38 -- * Response
servant-client-core/src/Servant/Client/Core/ClientError.hs+5−5
@@ -9,7 +9,7 @@
9{-# LANGUAGE ScopedTypeVariables #-}
9{-# LANGUAGE ScopedTypeVariables #-}
10{-# LANGUAGE TypeFamilies #-}
10{-# LANGUAGE TypeFamilies #-}
11module Servant.Client.Core.ClientError (
11module Servant.Client.Core.ClientError (
12− ServantError (..),
12+ ClientError (..),
13 ) where
13 ) where
14
14
15import Prelude ()
15import Prelude ()
@@ -42,7 +42,7 @@ import Servant.Client.Core.Response
42-- | A type representing possible errors in a request
42-- | A type representing possible errors in a request
43--
43--
44-- Note that this type substantially changed in 0.12.
44-- Note that this type substantially changed in 0.12.
45−data ServantError =
45+data ClientError =
46 -- | The server returned an error response including the
46 -- | The server returned an error response including the
47 -- failing request. 'requestPath' includes the 'BaseUrl' and the
47 -- failing request. 'requestPath' includes the 'BaseUrl' and the
48 -- path of the request.
48 -- path of the request.
@@ -57,7 +57,7 @@ data ServantError =
57 | ConnectionError SomeException
57 | ConnectionError SomeException
58 deriving (Show, Generic, Typeable)
58 deriving (Show, Generic, Typeable)
59
59
60−instance Eq ServantError where
60+instance Eq ClientError where
61 FailureResponse req res == FailureResponse req' res' = req == req' && res == res'
61 FailureResponse req res == FailureResponse req' res' = req == req' && res == res'
62 DecodeFailure t r == DecodeFailure t' r' = t == t' && r == r'
62 DecodeFailure t r == DecodeFailure t' r' = t == t' && r == r'
63 UnsupportedContentType mt r == UnsupportedContentType mt' r' = mt == mt' && r == r'
63 UnsupportedContentType mt r == UnsupportedContentType mt' r' = mt == mt' && r == r'
@@ -74,11 +74,11 @@ instance Eq ServantError where
74 InvalidContentTypeHeader {} == _ = False
74 InvalidContentTypeHeader {} == _ = False
75 ConnectionError {} == _ = False
75 ConnectionError {} == _ = False
76
76
77−instance Exception ServantError
77+instance Exception ClientError
78
78
79-- | Note: an exception in 'ConnectionError' might not be evaluated fully,
79-- | Note: an exception in 'ConnectionError' might not be evaluated fully,
80-- We only 'rnf' its 'show'ed value.
80-- We only 'rnf' its 'show'ed value.
81−instance NFData ServantError where
81+instance NFData ClientError where
82 rnf (FailureResponse req res) = rnf req `seq` rnf res
82 rnf (FailureResponse req res) = rnf req `seq` rnf res
83 rnf (DecodeFailure err res) = rnf err `seq` rnf res
83 rnf (DecodeFailure err res) = rnf err `seq` rnf res
84 rnf (UnsupportedContentType mt' res) = mediaTypeRnf mt' `seq` rnf res
84 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 #-}
254 , requestAccept = fromList $ toList accept
254 , requestAccept = fromList $ toList accept
255 }
255 }
256 case mimeUnrender (Proxy :: Proxy ct) $ responseBody response of
256 case mimeUnrender (Proxy :: Proxy ct) $ responseBody response of
257− Left err -> throwServantError $ DecodeFailure (pack err) response
257+ Left err -> throwClientError $ DecodeFailure (pack err) response
258 Right val -> return $ Headers
258 Right val -> return $ Headers
259 { getResponse = val
259 { getResponse = val
260 , getHeadersHList = buildHeadersTo . toList $ responseHeaders response
260 , getHeadersHList = buildHeadersTo . toList $ responseHeaders response
@@ -662,7 +662,7 @@ checkContentTypeHeader response =
662 case lookup "Content-Type" $ toList $ responseHeaders response of
662 case lookup "Content-Type" $ toList $ responseHeaders response of
663 Nothing -> return $ "application"//"octet-stream"
663 Nothing -> return $ "application"//"octet-stream"
664 Just t -> case parseAccept t of
664 Just t -> case parseAccept t of
665− Nothing -> throwServantError $ InvalidContentTypeHeader response
665+ Nothing -> throwClientError $ InvalidContentTypeHeader response
666 Just t' -> return t'
666 Just t' -> return t'
667
667
668decodedAs :: forall ct a m. (MimeUnrender ct a, RunClient m)
668decodedAs :: forall ct a m. (MimeUnrender ct a, RunClient m)
@@ -670,9 +670,9 @@ decodedAs :: forall ct a m. (MimeUnrender ct a, RunClient m)
670decodedAs response ct = do
670decodedAs response ct = do
671 responseContentType <- checkContentTypeHeader response
671 responseContentType <- checkContentTypeHeader response
672 unless (any (matches responseContentType) accept) $
672 unless (any (matches responseContentType) accept) $
673− throwServantError $ UnsupportedContentType responseContentType response
673+ throwClientError $ UnsupportedContentType responseContentType response
674 case mimeUnrender ct $ responseBody response of
674 case mimeUnrender ct $ responseBody response of
675− Left err -> throwServantError $ DecodeFailure (T.pack err) response
675+ Left err -> throwClientError $ DecodeFailure (T.pack err) response
676 Right val -> return val
676 Right val -> return val
677 where
677 where
678 accept = toList $ contentTypes ct
678 accept = toList $ contentTypes ct
servant-client-core/src/Servant/Client/Core/Reexport.hs+1−1
@@ -12,7 +12,7 @@ module Servant.Client.Core.Reexport
12 , ResponseF(..)
12 , ResponseF(..)
13
13
14 -- * Data types
14 -- * Data types
15− , ServantError(..)
15+ , ClientError(..)
16 , EmptyClient(..)
16 , EmptyClient(..)
17
17
18 -- * BaseUrl
18 -- * BaseUrl
servant-client-core/src/Servant/Client/Core/RunClient.hs+3−3
@@ -24,7 +24,7 @@ import Servant.Client.Core.Response
24class Monad m => RunClient m where
24class Monad m => RunClient m where
25 -- | How to make a request.
25 -- | How to make a request.
26 runRequest :: Request -> m Response
26 runRequest :: Request -> m Response
27− throwServantError :: ServantError -> m a
27+ throwClientError :: ClientError -> m a
28
28
29class RunClient m => RunStreamingClient m where
29class RunClient m => RunStreamingClient m where
30 withStreamingRequest :: Request -> (StreamingResponse -> IO a) -> m a
30 withStreamingRequest :: Request -> (StreamingResponse -> IO a) -> m a
@@ -38,9 +38,9 @@ class RunClient m => RunStreamingClient m where
38-- Compare to 'RunClient'.
38-- Compare to 'RunClient'.
39data ClientF a
39data ClientF a
40 = RunRequest Request (Response -> a)
40 = RunRequest Request (Response -> a)
41− | Throw ServantError
41+ | Throw ClientError
42 deriving (Functor)
42 deriving (Functor)
43
43
44instance ClientF ~ f => RunClient (Free f) where
44instance ClientF ~ f => RunClient (Free f) where
45 runRequest req = liftF (RunRequest req id)
45 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)
94--
94--
95-- NOTE: Does not support constant space streaming of the request body!
95-- NOTE: Does not support constant space streaming of the request body!
96newtype ClientM a = ClientM
96newtype ClientM a = ClientM
97− { runClientM' :: ReaderT ClientEnv (ExceptT ServantError IO) a }
97+ { runClientM' :: ReaderT ClientEnv (ExceptT ClientError IO) a }
98 deriving ( Functor, Applicative, Monad, MonadIO, Generic
98 deriving ( Functor, Applicative, Monad, MonadIO, Generic
99− , MonadReader ClientEnv, MonadError ServantError, MonadThrow
99+ , MonadReader ClientEnv, MonadError ClientError, MonadThrow
100 , MonadCatch)
100 , MonadCatch)
101
101
102instance MonadBase IO ClientM where
102instance MonadBase IO ClientM where
103 liftBase = ClientM . liftBase
103 liftBase = ClientM . liftBase
104
104
105instance MonadBaseControl IO ClientM where
105instance MonadBaseControl IO ClientM where
106− type StM ClientM a = Either ServantError a
106+ type StM ClientM a = Either ClientError a
107
107
108 liftBaseWith f = ClientM (liftBaseWith (\g -> f (g . runClientM')))
108 liftBaseWith f = ClientM (liftBaseWith (\g -> f (g . runClientM')))
109
109
@@ -121,12 +121,12 @@ instance Exception StreamingNotSupportedException where
121
121
122instance RunClient ClientM where
122instance RunClient ClientM where
123 runRequest = performRequest
123 runRequest = performRequest
124− throwServantError = throwError
124+ throwClientError = throwError
125
125
126−runClientMOrigin :: ClientM a -> ClientEnv -> IO (Either ServantError a)
126+runClientMOrigin :: ClientM a -> ClientEnv -> IO (Either ClientError a)
127runClientMOrigin cm env = runExceptT $ flip runReaderT env $ runClientM' cm
127runClientMOrigin cm env = runExceptT $ flip runReaderT env $ runClientM' cm
128
128
129−runClientM :: ClientM a -> IO (Either ServantError a)
129+runClientM :: ClientM a -> IO (Either ClientError a)
130runClientM m = do
130runClientM m = do
131 curLoc <- getWindowLocation
131 curLoc <- getWindowLocation
132
132
@@ -298,7 +298,7 @@ foreign import javascript unsafe "$3.slice($1, $1 + $2)"
298-- * inspecting the xhr response
298-- * inspecting the xhr response
299
299
300-- This function is only supposed to handle 'ConnectionError's. Other
300-- 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.
302toResponse :: JSXMLHttpRequest -> ClientM Response
302toResponse :: JSXMLHttpRequest -> ClientM Response
303toResponse xhr = do
303toResponse xhr = do
304 status <- liftIO $ getStatus xhr
304 status <- liftIO $ getStatus xhr
servant-client/src/Servant/Client/Internal/HttpClient.hs+7−7
@@ -120,16 +120,16 @@ hoistClient = hoistClientMonad (Proxy :: Proxy ClientM)
120-- | @ClientM@ is the monad in which client functions run. Contains the
120-- | @ClientM@ is the monad in which client functions run. Contains the
121-- 'Client.Manager' and 'BaseUrl' used for requests in the reader environment.
121-- 'Client.Manager' and 'BaseUrl' used for requests in the reader environment.
122newtype ClientM a = ClientM
122newtype ClientM a = ClientM
123− { unClientM :: ReaderT ClientEnv (ExceptT ServantError IO) a }
123+ { unClientM :: ReaderT ClientEnv (ExceptT ClientError IO) a }
124 deriving ( Functor, Applicative, Monad, MonadIO, Generic
124 deriving ( Functor, Applicative, Monad, MonadIO, Generic
125− , MonadReader ClientEnv, MonadError ServantError, MonadThrow
125+ , MonadReader ClientEnv, MonadError ClientError, MonadThrow
126 , MonadCatch)
126 , MonadCatch)
127
127
128instance MonadBase IO ClientM where
128instance MonadBase IO ClientM where
129 liftBase = ClientM . liftBase
129 liftBase = ClientM . liftBase
130
130
131instance MonadBaseControl IO ClientM where
131instance MonadBaseControl IO ClientM where
132− type StM ClientM a = Either ServantError a
132+ type StM ClientM a = Either ClientError a
133
133
134 liftBaseWith f = ClientM (liftBaseWith (\g -> f (g . unClientM)))
134 liftBaseWith f = ClientM (liftBaseWith (\g -> f (g . unClientM)))
135
135
@@ -141,9 +141,9 @@ instance Alt ClientM where
141
141
142instance RunClient ClientM where
142instance RunClient ClientM where
143 runRequest = performRequest
143 runRequest = performRequest
144− throwServantError = throwError
144+ throwClientError = throwError
145
145
146−runClientM :: ClientM a -> ClientEnv -> IO (Either ServantError a)
146+runClientM :: ClientM a -> ClientEnv -> IO (Either ClientError a)
147runClientM cm env = runExceptT $ flip runReaderT env $ unClientM cm
147runClientM cm env = runExceptT $ flip runReaderT env $ unClientM cm
148
148
149performRequest :: Request -> ClientM Response
149performRequest :: Request -> ClientM Response
@@ -197,7 +197,7 @@ performRequest req = do
197 fReq = Client.hrFinalRequest responses
197 fReq = Client.hrFinalRequest responses
198 fRes = Client.hrFinalResponse responses
198 fRes = Client.hrFinalResponse responses
199
199
200−mkFailureResponse :: BaseUrl -> Request -> ResponseF BSL.ByteString -> ServantError
200+mkFailureResponse :: BaseUrl -> Request -> ResponseF BSL.ByteString -> ClientError
201mkFailureResponse burl request =
201mkFailureResponse burl request =
202 FailureResponse (bimap (const ()) f request)
202 FailureResponse (bimap (const ()) f request)
203 where
203 where
@@ -270,7 +270,7 @@ requestToClientRequest burl r = Client.defaultRequest
270 Http -> False
270 Http -> False
271 Https -> True
271 Https -> True
272
272
273−catchConnectionError :: IO a -> IO (Either ServantError a)
273+catchConnectionError :: IO a -> IO (Either ClientError a)
274catchConnectionError action =
274catchConnectionError action =
275 catch (Right <$> action) $ \e ->
275 catch (Right <$> action) $ \e ->
276 pure . Left . ConnectionError $ SomeException (e :: Client.HttpException)
276 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)
100-- | @ClientM@ is the monad in which client functions run. Contains the
100-- | @ClientM@ is the monad in which client functions run. Contains the
101-- 'Client.Manager' and 'BaseUrl' used for requests in the reader environment.
101-- 'Client.Manager' and 'BaseUrl' used for requests in the reader environment.
102newtype ClientM a = ClientM
102newtype ClientM a = ClientM
103− { unClientM :: ReaderT ClientEnv (ExceptT ServantError (Codensity IO)) a }
103+ { unClientM :: ReaderT ClientEnv (ExceptT ClientError (Codensity IO)) a }
104 deriving ( Functor, Applicative, Monad, MonadIO, Generic
104 deriving ( Functor, Applicative, Monad, MonadIO, Generic
105− , MonadReader ClientEnv, MonadError ServantError)
105+ , MonadReader ClientEnv, MonadError ClientError)
106
106
107instance MonadBase IO ClientM where
107instance MonadBase IO ClientM where
108 liftBase = ClientM . liftIO
108 liftBase = ClientM . liftIO
@@ -113,12 +113,12 @@ instance Alt ClientM where
113
113
114instance RunClient ClientM where
114instance RunClient ClientM where
115 runRequest = performRequest
115 runRequest = performRequest
116− throwServantError = throwError
116+ throwClientError = throwError
117
117
118instance RunStreamingClient ClientM where
118instance RunStreamingClient ClientM where
119 withStreamingRequest = performWithStreamingRequest
119 withStreamingRequest = performWithStreamingRequest
120
120
121−withClientM :: ClientM a -> ClientEnv -> (Either ServantError a -> IO b) -> IO b
121+withClientM :: ClientM a -> ClientEnv -> (Either ClientError a -> IO b) -> IO b
122withClientM cm env k =
122withClientM cm env k =
123 let Codensity f = runExceptT $ flip runReaderT env $ unClientM cm
123 let Codensity f = runExceptT $ flip runReaderT env $ unClientM cm
124 in f k
124 in f k
@@ -133,7 +133,7 @@ withClientM cm env k =
133-- /Note:/ we 'force' the result, so the likehood of accidentally leaking a
133-- /Note:/ we 'force' the result, so the likehood of accidentally leaking a
134-- connection is smaller. Use with care.
134-- connection is smaller. Use with care.
135--
135--
136−runClientM :: NFData a => ClientM a -> ClientEnv -> IO (Either ServantError a)
136+runClientM :: NFData a => ClientM a -> ClientEnv -> IO (Either ClientError a)
137runClientM cm env = withClientM cm env (evaluate . force)
137runClientM cm env = withClientM cm env (evaluate . force)
138
138
139performRequest :: Request -> ClientM Response
139performRequest :: Request -> ClientM Response
servant-client/test/Servant/ClientSpec.hs+5−5
@@ -184,8 +184,8 @@ server = serve api (
184 :<|> return
184 :<|> return
185 :<|> (\ name -> case name of
185 :<|> (\ name -> case name of
186 Just "alice" -> return alice
186 Just "alice" -> return alice
187− Just n -> throwError $ ServantErr 400 (n ++ " not found") "" []
187+ Just n -> throwError $ ServerError 400 (n ++ " not found") "" []
188− Nothing -> throwError $ ServantErr 400 "missing parameter" "" [])
188+ Nothing -> throwError $ ServerError 400 "missing parameter" "" [])
189 :<|> (\ names -> return (zipWith Person names [0..]))
189 :<|> (\ names -> return (zipWith Person names [0..]))
190 :<|> return
190 :<|> return
191 :<|> (Tagged $ \ _request respond -> respond $ Wai.responseLBS HTTP.ok200 [] "rawSuccess")
191 :<|> (Tagged $ \ _request respond -> respond $ Wai.responseLBS HTTP.ok200 [] "rawSuccess")
@@ -260,7 +260,7 @@ genAuthServer = serveWithContext genAuthAPI genAuthServerContext (const (return
260manager' :: C.Manager
260manager' :: C.Manager
261manager' = unsafePerformIO $ C.newManager C.defaultManagerSettings
261manager' = unsafePerformIO $ C.newManager C.defaultManagerSettings
262
262
263−runClient :: ClientM a -> BaseUrl -> IO (Either ServantError a)
263+runClient :: ClientM a -> BaseUrl -> IO (Either ClientError a)
264runClient x baseUrl' = runClientM x (mkClientEnv manager' baseUrl')
264runClient x baseUrl' = runClientM x (mkClientEnv manager' baseUrl')
265
265
266sucessSpec :: Spec
266sucessSpec :: Spec
@@ -352,7 +352,7 @@ sucessSpec = beforeAll (startWaiApp server) $ afterAll endWaiApp $ do
352
352
353wrappedApiSpec :: Spec
353wrappedApiSpec :: Spec
354wrappedApiSpec = describe "error status codes" $ do
354wrappedApiSpec = 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" "" []
356 context "are correctly handled by the client" $
356 context "are correctly handled by the client" $
357 let test :: (WrappedApi, String) -> Spec
357 let test :: (WrappedApi, String) -> Spec
358 test (WrappedApi api, desc) =
358 test (WrappedApi api, desc) =
@@ -475,7 +475,7 @@ connectionErrorAPI :: Proxy ConnectionErrorAPI
475connectionErrorAPI = Proxy
475connectionErrorAPI = Proxy
476
476
477connectionErrorSpec :: Spec
477connectionErrorSpec :: Spec
478−connectionErrorSpec = describe "Servant.Client.ServantError" $
478+connectionErrorSpec = describe "Servant.Client.ClientError" $
479 it "correctly catches ConnectionErrors when the HTTP request can't go through" $ do
479 it "correctly catches ConnectionErrors when the HTTP request can't go through" $ do
480 let getInt = client connectionErrorAPI
480 let getInt = client connectionErrorAPI
481 let baseUrl' = BaseUrl Http "example.invalid" 80 ""
481 let baseUrl' = BaseUrl Http "example.invalid" 80 ""
servant-client/test/Servant/StreamSpec.hs+1−1
@@ -112,7 +112,7 @@ powerOfTwo = (2 ^)
112manager' :: C.Manager
112manager' :: C.Manager
113manager' = unsafePerformIO $ C.newManager C.defaultManagerSettings
113manager' = unsafePerformIO $ C.newManager C.defaultManagerSettings
114
114
115−withClient :: ClientM a -> BaseUrl -> (Either ServantError a -> IO r) -> IO r
115+withClient :: ClientM a -> BaseUrl -> (Either ClientError a -> IO r) -> IO r
116withClient x baseUrl' = withClientM x (mkClientEnv manager' baseUrl')
116withClient x baseUrl' = withClientM x (mkClientEnv manager' baseUrl')
117
117
118testRunSourceIO :: SourceIO a
118testRunSourceIO :: SourceIO a
servant-http-streams/src/Servant/HttpStreams/Internal.hs+7−7
@@ -123,9 +123,9 @@ hoistClient = hoistClientMonad (Proxy :: Proxy ClientM)
123-- | @ClientM@ is the monad in which client functions run. Contains the
123-- | @ClientM@ is the monad in which client functions run. Contains the
124-- 'Client.Manager' and 'BaseUrl' used for requests in the reader environment.
124-- 'Client.Manager' and 'BaseUrl' used for requests in the reader environment.
125newtype ClientM a = ClientM
125newtype ClientM a = ClientM
126− { unClientM :: ReaderT ClientEnv (ExceptT ServantError (Codensity IO)) a }
126+ { unClientM :: ReaderT ClientEnv (ExceptT ClientError (Codensity IO)) a }
127 deriving ( Functor, Applicative, Monad, MonadIO, Generic
127 deriving ( Functor, Applicative, Monad, MonadIO, Generic
128− , MonadReader ClientEnv, MonadError ServantError)
128+ , MonadReader ClientEnv, MonadError ClientError)
129
129
130instance MonadBase IO ClientM where
130instance MonadBase IO ClientM where
131 liftBase = ClientM . liftIO
131 liftBase = ClientM . liftIO
@@ -136,15 +136,15 @@ instance Alt ClientM where
136
136
137instance RunClient ClientM where
137instance RunClient ClientM where
138 runRequest = performRequest
138 runRequest = performRequest
139− throwServantError = throwError
139+ throwClientError = throwError
140
140
141instance RunStreamingClient ClientM where
141instance RunStreamingClient ClientM where
142 withStreamingRequest = performWithStreamingRequest
142 withStreamingRequest = performWithStreamingRequest
143
143
144−runClientM :: NFData a => ClientM a -> ClientEnv -> IO (Either ServantError a)
144+runClientM :: NFData a => ClientM a -> ClientEnv -> IO (Either ClientError a)
145runClientM cm env = withClientM cm env (evaluate . force)
145runClientM cm env = withClientM cm env (evaluate . force)
146
146
147−withClientM :: ClientM a -> ClientEnv -> (Either ServantError a -> IO b) -> IO b
147+withClientM :: ClientM a -> ClientEnv -> (Either ClientError a -> IO b) -> IO b
148withClientM cm env k =
148withClientM cm env k =
149 let Codensity f = runExceptT $ flip runReaderT env $ unClientM cm
149 let Codensity f = runExceptT $ flip runReaderT env $ unClientM cm
150 in f k
150 in f k
@@ -181,7 +181,7 @@ performWithStreamingRequest req k = do
181 x <- k (clientResponseToResponse res' (fromInputStream body'))
181 x <- k (clientResponseToResponse res' (fromInputStream body'))
182 k1 x
182 k1 x
183
183
184−mkFailureResponse :: BaseUrl -> Request -> ResponseF BSL.ByteString -> ServantError
184+mkFailureResponse :: BaseUrl -> Request -> ResponseF BSL.ByteString -> ClientError
185mkFailureResponse burl request =
185mkFailureResponse burl request =
186 FailureResponse (bimap (const ()) f request)
186 FailureResponse (bimap (const ()) f request)
187 where
187 where
@@ -233,7 +233,7 @@ requestToClientRequest burl r = (request, body)
233 Nothing -> (Client.emptyBody, Nothing)
233 Nothing -> (Client.emptyBody, Nothing)
234 Just (body', typ) -> (convertBody body', Just (hContentType, renderHeader typ))
234 Just (body', typ) -> (convertBody body', Just (hContentType, renderHeader typ))
235
235
236−catchConnectionError :: IO a -> IO (Either ServantError a)
236+catchConnectionError :: IO a -> IO (Either ClientError a)
237catchConnectionError action =
237catchConnectionError action =
238 catch (Right <$> action) $ \e ->
238 catch (Right <$> action) $ \e ->
239 pure . Left . ConnectionError $ SomeException (e :: IOException)
239 pure . Left . ConnectionError $ SomeException (e :: IOException)
servant-http-streams/test/Servant/ClientSpec.hs+6−6
@@ -182,8 +182,8 @@ server = serve api (
182 :<|> return
182 :<|> return
183 :<|> (\ name -> case name of
183 :<|> (\ name -> case name of
184 Just "alice" -> return alice
184 Just "alice" -> return alice
185− Just n -> throwError $ ServantErr 400 (n ++ " not found") "" []
185+ Just n -> throwError $ ServerError 400 (n ++ " not found") "" []
186− Nothing -> throwError $ ServantErr 400 "missing parameter" "" [])
186+ Nothing -> throwError $ ServerError 400 "missing parameter" "" [])
187 :<|> (\ names -> return (zipWith Person names [0..]))
187 :<|> (\ names -> return (zipWith Person names [0..]))
188 :<|> return
188 :<|> return
189 :<|> (Tagged $ \ _request respond -> respond $ Wai.responseLBS HTTP.ok200 [] "rawSuccess")
189 :<|> (Tagged $ \ _request respond -> respond $ Wai.responseLBS HTTP.ok200 [] "rawSuccess")
@@ -254,10 +254,10 @@ genAuthServerContext = genAuthHandler :. EmptyContext
254genAuthServer :: Application
254genAuthServer :: Application
255genAuthServer = serveWithContext genAuthAPI genAuthServerContext (const (return alice))
255genAuthServer = serveWithContext genAuthAPI genAuthServerContext (const (return alice))
256
256
257−runClient :: NFData a => ClientM a -> BaseUrl -> IO (Either ServantError a)
257+runClient :: NFData a => ClientM a -> BaseUrl -> IO (Either ClientError a)
258runClient x burl = withClientEnvIO burl (runClientM x)
258runClient x burl = withClientEnvIO burl (runClientM x)
259
259
260−runClientUnsafe :: ClientM a -> BaseUrl -> IO (Either ServantError a)
260+runClientUnsafe :: ClientM a -> BaseUrl -> IO (Either ClientError a)
261runClientUnsafe x burl = withClientEnvIO burl (runClientMUnsafe x)
261runClientUnsafe x burl = withClientEnvIO burl (runClientMUnsafe x)
262 where
262 where
263 runClientMUnsafe x env = withClientM x env return
263 runClientMUnsafe x env = withClientM x env return
@@ -343,7 +343,7 @@ sucessSpec = beforeAll (startWaiApp server) $ afterAll endWaiApp $ do
343
343
344wrappedApiSpec :: Spec
344wrappedApiSpec :: Spec
345wrappedApiSpec = describe "error status codes" $ do
345wrappedApiSpec = 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" "" []
347 context "are correctly handled by the client" $
347 context "are correctly handled by the client" $
348 let test :: (WrappedApi, String) -> Spec
348 let test :: (WrappedApi, String) -> Spec
349 test (WrappedApi api, desc) =
349 test (WrappedApi api, desc) =
@@ -467,7 +467,7 @@ connectionErrorAPI :: Proxy ConnectionErrorAPI
467connectionErrorAPI = Proxy
467connectionErrorAPI = Proxy
468
468
469connectionErrorSpec :: Spec
469connectionErrorSpec :: Spec
470−connectionErrorSpec = describe "Servant.Client.ServantError" $
470+connectionErrorSpec = describe "Servant.Client.ClientError" $
471 xit "correctly catches ConnectionErrors when the HTTP request can't go through" $ do
471 xit "correctly catches ConnectionErrors when the HTTP request can't go through" $ do
472 let getInt = client connectionErrorAPI
472 let getInt = client connectionErrorAPI
473 let baseUrl' = BaseUrl Http "example.invalid" 80 ""
473 let baseUrl' = BaseUrl Http "example.invalid" 80 ""
servant-http-streams/test/Servant/StreamSpec.hs+1−1
@@ -84,7 +84,7 @@ server = serve api
84powerOfTwo :: Int -> Int
84powerOfTwo :: Int -> Int
85powerOfTwo = (2 ^)
85powerOfTwo = (2 ^)
86
86
87−withClient :: ClientM a -> BaseUrl -> (Either ServantError a -> IO r) -> IO r
87+withClient :: ClientM a -> BaseUrl -> (Either ClientError a -> IO r) -> IO r
88withClient x burl k = do
88withClient x burl k = do
89 withClientEnvIO burl $ \env -> withClientM x env k
89 withClientEnvIO burl $ \env -> withClientM x env k
90
90
servant-server/servant-server.cabal+1−1
@@ -55,7 +55,7 @@ library
55 Servant.Server.Internal.Handler
55 Servant.Server.Internal.Handler
56 Servant.Server.Internal.Router
56 Servant.Server.Internal.Router
57 Servant.Server.Internal.RoutingApplication
57 Servant.Server.Internal.RoutingApplication
58− Servant.Server.Internal.ServantErr
58+ Servant.Server.Internal.ServerError
59 Servant.Server.StaticFiles
59 Servant.Server.StaticFiles
60
60
61 -- deprecated
61 -- deprecated
servant-server/src/Servant/Server.hs+1−1
@@ -49,7 +49,7 @@ module Servant.Server
49 -- , mkAuthHandler
49 -- , mkAuthHandler
50
50
51 -- * Default error type
51 -- * Default error type
52− , ServantErr(..)
52+ , ServerError(..)
53 -- ** 3XX
53 -- ** 3XX
54 , err300
54 , err300
55 , err301
55 , err301
servant-server/src/Servant/Server/Internal.hs+2−2
@@ -25,7 +25,7 @@ module Servant.Server.Internal
25 , module Servant.Server.Internal.Handler
25 , module Servant.Server.Internal.Handler
26 , module Servant.Server.Internal.Router
26 , module Servant.Server.Internal.Router
27 , module Servant.Server.Internal.RoutingApplication
27 , module Servant.Server.Internal.RoutingApplication
28− , module Servant.Server.Internal.ServantErr
28+ , module Servant.Server.Internal.ServerError
29 ) where
29 ) where
30
30
31import Control.Monad
31import Control.Monad
@@ -91,7 +91,7 @@ import Servant.Server.Internal.Context
91import Servant.Server.Internal.Handler
91import Servant.Server.Internal.Handler
92import Servant.Server.Internal.Router
92import Servant.Server.Internal.Router
93import Servant.Server.Internal.RoutingApplication
93import Servant.Server.Internal.RoutingApplication
94−import Servant.Server.Internal.ServantErr
94+import Servant.Server.Internal.ServerError
95
95
96#ifdef HAS_TYPE_ERROR
96#ifdef HAS_TYPE_ERROR
97import GHC.TypeLits
97import GHC.TypeLits
servant-server/src/Servant/Server/Internal/BasicAuth.hs+1−1
@@ -27,7 +27,7 @@ import Network.Wai
27import Servant.API.BasicAuth
27import Servant.API.BasicAuth
28 (BasicAuthData (BasicAuthData))
28 (BasicAuthData (BasicAuthData))
29import Servant.Server.Internal.RoutingApplication
29import Servant.Server.Internal.RoutingApplication
30−import Servant.Server.Internal.ServantErr
30+import Servant.Server.Internal.ServerError
31
31
32-- * Basic Auth
32-- * Basic Auth
33
33
servant-server/src/Servant/Server/Internal/Handler.hs+6−6
@@ -22,13 +22,13 @@ import Control.Monad.Trans.Except
22 (ExceptT, runExceptT)
22 (ExceptT, runExceptT)
23import GHC.Generics
23import GHC.Generics
24 (Generic)
24 (Generic)
25−import Servant.Server.Internal.ServantErr
25+import Servant.Server.Internal.ServerError
26− (ServantErr)
26+ (ServerError)
27
27
28−newtype Handler a = Handler { runHandler' :: ExceptT ServantErr IO a }
28+newtype Handler a = Handler { runHandler' :: ExceptT ServerError IO a }
29 deriving
29 deriving
30 ( Functor, Applicative, Monad, MonadIO, Generic
30 ( Functor, Applicative, Monad, MonadIO, Generic
31− , MonadError ServantErr
31+ , MonadError ServerError
32 , MonadThrow, MonadCatch, MonadMask
32 , MonadThrow, MonadCatch, MonadMask
33 )
33 )
34
34
@@ -36,7 +36,7 @@ instance MonadBase IO Handler where
36 liftBase = Handler . liftBase
36 liftBase = Handler . liftBase
37
37
38instance MonadBaseControl IO Handler where
38instance MonadBaseControl IO Handler where
39− type StM Handler a = Either ServantErr a
39+ type StM Handler a = Either ServerError a
40
40
41 -- liftBaseWith :: (RunInBase Handler IO -> IO a) -> Handler a
41 -- liftBaseWith :: (RunInBase Handler IO -> IO a) -> Handler a
42 liftBaseWith f = Handler (liftBaseWith (\g -> f (g . runHandler')))
42 liftBaseWith f = Handler (liftBaseWith (\g -> f (g . runHandler')))
@@ -44,5 +44,5 @@ instance MonadBaseControl IO Handler where
44 -- restoreM :: StM Handler a -> Handler a
44 -- restoreM :: StM Handler a -> Handler a
45 restoreM st = Handler (restoreM st)
45 restoreM st = Handler (restoreM st)
46
46
47−runHandler :: Handler a -> IO (Either ServantErr a)
47+runHandler :: Handler a -> IO (Either ServerError a)
48runHandler = runExceptT . runHandler'
48runHandler = runExceptT . runHandler'
servant-server/src/Servant/Server/Internal/Router.hs+1−1
@@ -18,7 +18,7 @@ import qualified Data.Text as T
18import Network.Wai
18import Network.Wai
19 (Response, pathInfo)
19 (Response, pathInfo)
20import Servant.Server.Internal.RoutingApplication
20import Servant.Server.Internal.RoutingApplication
21−import Servant.Server.Internal.ServantErr
21+import Servant.Server.Internal.ServerError
22
22
23type Router env = Router' env RoutingApplication
23type Router env = Router' env RoutingApplication
24
24
servant-server/src/Servant/Server/Internal/RoutingApplication.hs+8−8
@@ -31,7 +31,7 @@ import Network.Wai
31import Prelude ()
31import Prelude ()
32import Prelude.Compat
32import Prelude.Compat
33import Servant.Server.Internal.Handler
33import Servant.Server.Internal.Handler
34−import Servant.Server.Internal.ServantErr
34+import Servant.Server.Internal.ServerError
35
35
36type RoutingApplication =
36type RoutingApplication =
37 Request -- ^ the request, the field 'pathInfo' may be modified by url routing
37 Request -- ^ the request, the field 'pathInfo' may be modified by url routing
@@ -39,9 +39,9 @@ type RoutingApplication =
39
39
40-- | The result of matching against a path in the route tree.
40-- | The result of matching against a path in the route tree.
41data RouteResult a =
41data RouteResult a =
42− Fail ServantErr -- ^ Keep trying other paths. The @ServantErr@
42+ Fail ServerError -- ^ Keep trying other paths. The @ServantErr@
43 -- should only be 404, 405 or 406.
43 -- should only be 404, 405 or 406.
44− | FailFatal !ServantErr -- ^ Don't try other paths.
44+ | FailFatal !ServerError -- ^ Don't try other paths.
45 | Route !a
45 | Route !a
46 deriving (Eq, Show, Read, Functor)
46 deriving (Eq, Show, Read, Functor)
47
47
@@ -97,8 +97,8 @@ toApplication :: RoutingApplication -> Application
97toApplication ra request respond = ra request routingRespond
97toApplication ra request respond = ra request routingRespond
98 where
98 where
99 routingRespond :: RouteResult Response -> IO ResponseReceived
99 routingRespond :: RouteResult Response -> IO ResponseReceived
100− routingRespond (Fail err) = respond $ responseServantErr err
100+ routingRespond (Fail err) = respond $ responseServerError err
101− routingRespond (FailFatal err) = respond $ responseServantErr err
101+ routingRespond (FailFatal err) = respond $ responseServerError err
102 routingRespond (Route v) = respond v
102 routingRespond (Route v) = respond v
103
103
104-- | A 'Delayed' is a representation of a handler with scheduled
104-- | A 'Delayed' is a representation of a handler with scheduled
@@ -235,11 +235,11 @@ emptyDelayed result =
235 r = return ()
235 r = return ()
236
236
237-- | Fail with the option to recover.
237-- | Fail with the option to recover.
238−delayedFail :: ServantErr -> DelayedIO a
238+delayedFail :: ServerError -> DelayedIO a
239delayedFail err = liftRouteResult $ Fail err
239delayedFail err = liftRouteResult $ Fail err
240
240
241-- | Fail fatally, i.e., without any option to recover.
241-- | Fail fatally, i.e., without any option to recover.
242−delayedFailFatal :: ServantErr -> DelayedIO a
242+delayedFailFatal :: ServerError -> DelayedIO a
243delayedFailFatal err = liftRouteResult $ FailFatal err
243delayedFailFatal err = liftRouteResult $ FailFatal err
244
244
245-- | Gain access to the incoming request.
245-- | Gain access to the incoming request.
@@ -388,7 +388,7 @@ runAction action env req respond k = runResourceT $
388 go (Route a) = liftIO $ do
388 go (Route a) = liftIO $ do
389 e <- runHandler a
389 e <- runHandler a
390 case e of
390 case e of
391− Left err -> return . Route $ responseServantErr err
391+ Left err -> return . Route $ responseServerError err
392 Right x -> return $! k x
392 Right x -> return $! k x
393
393
394{- Note [Existential Record Update]
394{- 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 @@
1{-# LANGUAGE DeriveDataTypeable #-}
1{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE RecordWildCards #-}
3{-# LANGUAGE RecordWildCards #-}
4−module Servant.Server.Internal.ServantErr where
4+module Servant.Server.Internal.ServerError where
5
5
6import Control.Exception
6import Control.Exception
7 (Exception)
7 (Exception)
@@ -13,16 +13,18 @@ import qualified Network.HTTP.Types as HTTP
13import Network.Wai
13import Network.Wai
14 (Response, responseLBS)
14 (Response, responseLBS)
15
15
16+data ServerError = ServerError
16−data ServantErr = ServantErr { errHTTPCode :: Int
17+ { errHTTPCode :: Int
17− , errReasonPhrase :: String
18+ , errReasonPhrase :: String
18− , errBody :: LBS.ByteString
19+ , errBody :: LBS.ByteString
19− , errHeaders :: [HTTP.Header]
20+ , errHeaders :: [HTTP.Header]
21+ }
20− } deriving (Show, Eq, Read, Typeable)
22+ deriving (Show, Eq, Read, Typeable)
21
23
22−instance Exception ServantErr
24+instance Exception ServerError
23
25
24−responseServantErr :: ServantErr -> Response
26+responseServerError :: ServerError -> Response
25−responseServantErr ServantErr{..} = responseLBS status errHeaders errBody
27+responseServerError ServerError{..} = responseLBS status errHeaders errBody
26 where
28 where
27 status = HTTP.mkStatus errHTTPCode (BS.pack errReasonPhrase)
29 status = HTTP.mkStatus errHTTPCode (BS.pack errReasonPhrase)
28
30
@@ -33,8 +35,8 @@ responseServantErr ServantErr{..} = responseLBS status errHeaders errBody
33-- > failingHandler :: Handler ()
35-- > failingHandler :: Handler ()
34-- > failingHandler = throwError $ err300 { errBody = "I can't choose." }
36-- > failingHandler = throwError $ err300 { errBody = "I can't choose." }
35--
37--
36−err300 :: ServantErr
38+err300 :: ServerError
37−err300 = ServantErr { errHTTPCode = 300
39+err300 = ServerError { errHTTPCode = 300
38 , errReasonPhrase = "Multiple Choices"
40 , errReasonPhrase = "Multiple Choices"
39 , errBody = ""
41 , errBody = ""
40 , errHeaders = []
42 , errHeaders = []
@@ -47,8 +49,8 @@ err300 = ServantErr { errHTTPCode = 300
47-- > failingHandler :: Handler ()
49-- > failingHandler :: Handler ()
48-- > failingHandler = throwError err301
50-- > failingHandler = throwError err301
49--
51--
50−err301 :: ServantErr
52+err301 :: ServerError
51−err301 = ServantErr { errHTTPCode = 301
53+err301 = ServerError { errHTTPCode = 301
52 , errReasonPhrase = "Moved Permanently"
54 , errReasonPhrase = "Moved Permanently"
53 , errBody = ""
55 , errBody = ""
54 , errHeaders = []
56 , errHeaders = []
@@ -61,8 +63,8 @@ err301 = ServantErr { errHTTPCode = 301
61-- > failingHandler :: Handler ()
63-- > failingHandler :: Handler ()
62-- > failingHandler = throwError err302
64-- > failingHandler = throwError err302
63--
65--
64−err302 :: ServantErr
66+err302 :: ServerError
65−err302 = ServantErr { errHTTPCode = 302
67+err302 = ServerError { errHTTPCode = 302
66 , errReasonPhrase = "Found"
68 , errReasonPhrase = "Found"
67 , errBody = ""
69 , errBody = ""
68 , errHeaders = []
70 , errHeaders = []
@@ -75,8 +77,8 @@ err302 = ServantErr { errHTTPCode = 302
75-- > failingHandler :: Handler ()
77-- > failingHandler :: Handler ()
76-- > failingHandler = throwError err303
78-- > failingHandler = throwError err303
77--
79--
78−err303 :: ServantErr
80+err303 :: ServerError
79−err303 = ServantErr { errHTTPCode = 303
81+err303 = ServerError { errHTTPCode = 303
80 , errReasonPhrase = "See Other"
82 , errReasonPhrase = "See Other"
81 , errBody = ""
83 , errBody = ""
82 , errHeaders = []
84 , errHeaders = []
@@ -89,8 +91,8 @@ err303 = ServantErr { errHTTPCode = 303
89-- > failingHandler :: Handler ()
91-- > failingHandler :: Handler ()
90-- > failingHandler = throwError err304
92-- > failingHandler = throwError err304
91--
93--
92−err304 :: ServantErr
94+err304 :: ServerError
93−err304 = ServantErr { errHTTPCode = 304
95+err304 = ServerError { errHTTPCode = 304
94 , errReasonPhrase = "Not Modified"
96 , errReasonPhrase = "Not Modified"
95 , errBody = ""
97 , errBody = ""
96 , errHeaders = []
98 , errHeaders = []
@@ -103,8 +105,8 @@ err304 = ServantErr { errHTTPCode = 304
103-- > failingHandler :: Handler ()
105-- > failingHandler :: Handler ()
104-- > failingHandler = throwError err305
106-- > failingHandler = throwError err305
105--
107--
106−err305 :: ServantErr
108+err305 :: ServerError
107−err305 = ServantErr { errHTTPCode = 305
109+err305 = ServerError { errHTTPCode = 305
108 , errReasonPhrase = "Use Proxy"
110 , errReasonPhrase = "Use Proxy"
109 , errBody = ""
111 , errBody = ""
110 , errHeaders = []
112 , errHeaders = []
@@ -117,8 +119,8 @@ err305 = ServantErr { errHTTPCode = 305
117-- > failingHandler :: Handler ()
119-- > failingHandler :: Handler ()
118-- > failingHandler = throwError err307
120-- > failingHandler = throwError err307
119--
121--
120−err307 :: ServantErr
122+err307 :: ServerError
121−err307 = ServantErr { errHTTPCode = 307
123+err307 = ServerError { errHTTPCode = 307
122 , errReasonPhrase = "Temporary Redirect"
124 , errReasonPhrase = "Temporary Redirect"
123 , errBody = ""
125 , errBody = ""
124 , errHeaders = []
126 , errHeaders = []
@@ -131,8 +133,8 @@ err307 = ServantErr { errHTTPCode = 307
131-- > failingHandler :: Handler ()
133-- > failingHandler :: Handler ()
132-- > failingHandler = throwError $ err400 { errBody = "Your request makes no sense to me." }
134-- > failingHandler = throwError $ err400 { errBody = "Your request makes no sense to me." }
133--
135--
134−err400 :: ServantErr
136+err400 :: ServerError
135−err400 = ServantErr { errHTTPCode = 400
137+err400 = ServerError { errHTTPCode = 400
136 , errReasonPhrase = "Bad Request"
138 , errReasonPhrase = "Bad Request"
137 , errBody = ""
139 , errBody = ""
138 , errHeaders = []
140 , errHeaders = []
@@ -145,8 +147,8 @@ err400 = ServantErr { errHTTPCode = 400
145-- > failingHandler :: Handler ()
147-- > failingHandler :: Handler ()
146-- > failingHandler = throwError $ err401 { errBody = "Your credentials are invalid." }
148-- > failingHandler = throwError $ err401 { errBody = "Your credentials are invalid." }
147--
149--
148−err401 :: ServantErr
150+err401 :: ServerError
149−err401 = ServantErr { errHTTPCode = 401
151+err401 = ServerError { errHTTPCode = 401
150 , errReasonPhrase = "Unauthorized"
152 , errReasonPhrase = "Unauthorized"
151 , errBody = ""
153 , errBody = ""
152 , errHeaders = []
154 , errHeaders = []
@@ -159,8 +161,8 @@ err401 = ServantErr { errHTTPCode = 401
159-- > failingHandler :: Handler ()
161-- > failingHandler :: Handler ()
160-- > failingHandler = throwError $ err402 { errBody = "You have 0 credits. Please give me $$$." }
162-- > failingHandler = throwError $ err402 { errBody = "You have 0 credits. Please give me $$$." }
161--
163--
162−err402 :: ServantErr
164+err402 :: ServerError
163−err402 = ServantErr { errHTTPCode = 402
165+err402 = ServerError { errHTTPCode = 402
164 , errReasonPhrase = "Payment Required"
166 , errReasonPhrase = "Payment Required"
165 , errBody = ""
167 , errBody = ""
166 , errHeaders = []
168 , errHeaders = []
@@ -173,8 +175,8 @@ err402 = ServantErr { errHTTPCode = 402
173-- > failingHandler :: Handler ()
175-- > failingHandler :: Handler ()
174-- > failingHandler = throwError $ err403 { errBody = "Please login first." }
176-- > failingHandler = throwError $ err403 { errBody = "Please login first." }
175--
177--
176−err403 :: ServantErr
178+err403 :: ServerError
177−err403 = ServantErr { errHTTPCode = 403
179+err403 = ServerError { errHTTPCode = 403
178 , errReasonPhrase = "Forbidden"
180 , errReasonPhrase = "Forbidden"
179 , errBody = ""
181 , errBody = ""
180 , errHeaders = []
182 , errHeaders = []
@@ -187,8 +189,8 @@ err403 = ServantErr { errHTTPCode = 403
187-- > failingHandler :: Handler ()
189-- > failingHandler :: Handler ()
188-- > failingHandler = throwError $ err404 { errBody = "(╯°□°)╯︵ ┻━┻)." }
190-- > failingHandler = throwError $ err404 { errBody = "(╯°□°)╯︵ ┻━┻)." }
189--
191--
190−err404 :: ServantErr
192+err404 :: ServerError
191−err404 = ServantErr { errHTTPCode = 404
193+err404 = ServerError { errHTTPCode = 404
192 , errReasonPhrase = "Not Found"
194 , errReasonPhrase = "Not Found"
193 , errBody = ""
195 , errBody = ""
194 , errHeaders = []
196 , errHeaders = []
@@ -201,8 +203,8 @@ err404 = ServantErr { errHTTPCode = 404
201-- > failingHandler :: Handler ()
203-- > failingHandler :: Handler ()
202-- > failingHandler = throwError $ err405 { errBody = "Your account privileges does not allow for this. Please pay $$$." }
204-- > failingHandler = throwError $ err405 { errBody = "Your account privileges does not allow for this. Please pay $$$." }
203--
205--
204−err405 :: ServantErr
206+err405 :: ServerError
205−err405 = ServantErr { errHTTPCode = 405
207+err405 = ServerError { errHTTPCode = 405
206 , errReasonPhrase = "Method Not Allowed"
208 , errReasonPhrase = "Method Not Allowed"
207 , errBody = ""
209 , errBody = ""
208 , errHeaders = []
210 , errHeaders = []
@@ -215,8 +217,8 @@ err405 = ServantErr { errHTTPCode = 405
215-- > failingHandler :: Handler ()
217-- > failingHandler :: Handler ()
216-- > failingHandler = throwError err406
218-- > failingHandler = throwError err406
217--
219--
218−err406 :: ServantErr
220+err406 :: ServerError
219−err406 = ServantErr { errHTTPCode = 406
221+err406 = ServerError { errHTTPCode = 406
220 , errReasonPhrase = "Not Acceptable"
222 , errReasonPhrase = "Not Acceptable"
221 , errBody = ""
223 , errBody = ""
222 , errHeaders = []
224 , errHeaders = []
@@ -229,8 +231,8 @@ err406 = ServantErr { errHTTPCode = 406
229-- > failingHandler :: Handler ()
231-- > failingHandler :: Handler ()
230-- > failingHandler = throwError err407
232-- > failingHandler = throwError err407
231--
233--
232−err407 :: ServantErr
234+err407 :: ServerError
233−err407 = ServantErr { errHTTPCode = 407
235+err407 = ServerError { errHTTPCode = 407
234 , errReasonPhrase = "Proxy Authentication Required"
236 , errReasonPhrase = "Proxy Authentication Required"
235 , errBody = ""
237 , errBody = ""
236 , errHeaders = []
238 , errHeaders = []
@@ -243,8 +245,8 @@ err407 = ServantErr { errHTTPCode = 407
243-- > failingHandler :: Handler ()
245-- > failingHandler :: Handler ()
244-- > failingHandler = throwError $ err409 { errBody = "Transaction conflicts with 59879cb56c7c159231eeacdd503d755f7e835f74" }
246-- > failingHandler = throwError $ err409 { errBody = "Transaction conflicts with 59879cb56c7c159231eeacdd503d755f7e835f74" }
245--
247--
246−err409 :: ServantErr
248+err409 :: ServerError
247−err409 = ServantErr { errHTTPCode = 409
249+err409 = ServerError { errHTTPCode = 409
248 , errReasonPhrase = "Conflict"
250 , errReasonPhrase = "Conflict"
249 , errBody = ""
251 , errBody = ""
250 , errHeaders = []
252 , errHeaders = []
@@ -257,8 +259,8 @@ err409 = ServantErr { errHTTPCode = 409
257-- > failingHandler :: Handler ()
259-- > failingHandler :: Handler ()
258-- > failingHandler = throwError $ err410 { errBody = "I know it was here at some point, but.. I blame bad luck." }
260-- > failingHandler = throwError $ err410 { errBody = "I know it was here at some point, but.. I blame bad luck." }
259--
261--
260−err410 :: ServantErr
262+err410 :: ServerError
261−err410 = ServantErr { errHTTPCode = 410
263+err410 = ServerError { errHTTPCode = 410
262 , errReasonPhrase = "Gone"
264 , errReasonPhrase = "Gone"
263 , errBody = ""
265 , errBody = ""
264 , errHeaders = []
266 , errHeaders = []
@@ -271,8 +273,8 @@ err410 = ServantErr { errHTTPCode = 410
271-- > failingHandler :: Handler ()
273-- > failingHandler :: Handler ()
272-- > failingHandler = throwError err411
274-- > failingHandler = throwError err411
273--
275--
274−err411 :: ServantErr
276+err411 :: ServerError
275−err411 = ServantErr { errHTTPCode = 411
277+err411 = ServerError { errHTTPCode = 411
276 , errReasonPhrase = "Length Required"
278 , errReasonPhrase = "Length Required"
277 , errBody = ""
279 , errBody = ""
278 , errHeaders = []
280 , errHeaders = []
@@ -285,8 +287,8 @@ err411 = ServantErr { errHTTPCode = 411
285-- > failingHandler :: Handler ()
287-- > failingHandler :: Handler ()
286-- > failingHandler = throwError $ err412 { errBody = "Precondition fail: x < 42 && y > 57" }
288-- > failingHandler = throwError $ err412 { errBody = "Precondition fail: x < 42 && y > 57" }
287--
289--
288−err412 :: ServantErr
290+err412 :: ServerError
289−err412 = ServantErr { errHTTPCode = 412
291+err412 = ServerError { errHTTPCode = 412
290 , errReasonPhrase = "Precondition Failed"
292 , errReasonPhrase = "Precondition Failed"
291 , errBody = ""
293 , errBody = ""
292 , errHeaders = []
294 , errHeaders = []
@@ -299,8 +301,8 @@ err412 = ServantErr { errHTTPCode = 412
299-- > failingHandler :: Handler ()
301-- > failingHandler :: Handler ()
300-- > failingHandler = throwError $ err413 { errBody = "Request exceeded 64k." }
302-- > failingHandler = throwError $ err413 { errBody = "Request exceeded 64k." }
301--
303--
302−err413 :: ServantErr
304+err413 :: ServerError
303−err413 = ServantErr { errHTTPCode = 413
305+err413 = ServerError { errHTTPCode = 413
304 , errReasonPhrase = "Request Entity Too Large"
306 , errReasonPhrase = "Request Entity Too Large"
305 , errBody = ""
307 , errBody = ""
306 , errHeaders = []
308 , errHeaders = []
@@ -313,8 +315,8 @@ err413 = ServantErr { errHTTPCode = 413
313-- > failingHandler :: Handler ()
315-- > failingHandler :: Handler ()
314-- > failingHandler = throwError $ err414 { errBody = "Maximum length is 64." }
316-- > failingHandler = throwError $ err414 { errBody = "Maximum length is 64." }
315--
317--
316−err414 :: ServantErr
318+err414 :: ServerError
317−err414 = ServantErr { errHTTPCode = 414
319+err414 = ServerError { errHTTPCode = 414
318 , errReasonPhrase = "Request-URI Too Large"
320 , errReasonPhrase = "Request-URI Too Large"
319 , errBody = ""
321 , errBody = ""
320 , errHeaders = []
322 , errHeaders = []
@@ -327,8 +329,8 @@ err414 = ServantErr { errHTTPCode = 414
327-- > failingHandler :: Handler ()
329-- > failingHandler :: Handler ()
328-- > failingHandler = throwError $ err415 { errBody = "Supported media types: gif, png" }
330-- > failingHandler = throwError $ err415 { errBody = "Supported media types: gif, png" }
329--
331--
330−err415 :: ServantErr
332+err415 :: ServerError
331−err415 = ServantErr { errHTTPCode = 415
333+err415 = ServerError { errHTTPCode = 415
332 , errReasonPhrase = "Unsupported Media Type"
334 , errReasonPhrase = "Unsupported Media Type"
333 , errBody = ""
335 , errBody = ""
334 , errHeaders = []
336 , errHeaders = []
@@ -341,8 +343,8 @@ err415 = ServantErr { errHTTPCode = 415
341-- > failingHandler :: Handler ()
343-- > failingHandler :: Handler ()
342-- > failingHandler = throwError $ err416 { errBody = "Valid range is [0, 424242]." }
344-- > failingHandler = throwError $ err416 { errBody = "Valid range is [0, 424242]." }
343--
345--
344−err416 :: ServantErr
346+err416 :: ServerError
345−err416 = ServantErr { errHTTPCode = 416
347+err416 = ServerError { errHTTPCode = 416
346 , errReasonPhrase = "Request range not satisfiable"
348 , errReasonPhrase = "Request range not satisfiable"
347 , errBody = ""
349 , errBody = ""
348 , errHeaders = []
350 , errHeaders = []
@@ -355,8 +357,8 @@ err416 = ServantErr { errHTTPCode = 416
355-- > failingHandler :: Handler ()
357-- > failingHandler :: Handler ()
356-- > failingHandler = throwError $ err417 { errBody = "I found a quux in the request. This isn't going to work." }
358-- > failingHandler = throwError $ err417 { errBody = "I found a quux in the request. This isn't going to work." }
357--
359--
358−err417 :: ServantErr
360+err417 :: ServerError
359−err417 = ServantErr { errHTTPCode = 417
361+err417 = ServerError { errHTTPCode = 417
360 , errReasonPhrase = "Expectation Failed"
362 , errReasonPhrase = "Expectation Failed"
361 , errBody = ""
363 , errBody = ""
362 , errHeaders = []
364 , errHeaders = []
@@ -369,8 +371,8 @@ err417 = ServantErr { errHTTPCode = 417
369-- > failingHandler :: Handler ()
371-- > failingHandler :: Handler ()
370-- > failingHandler = throwError $ err418 { errBody = "Apologies, this is not a webserver but a teapot." }
372-- > failingHandler = throwError $ err418 { errBody = "Apologies, this is not a webserver but a teapot." }
371--
373--
372−err418 :: ServantErr
374+err418 :: ServerError
373−err418 = ServantErr { errHTTPCode = 418
375+err418 = ServerError { errHTTPCode = 418
374 , errReasonPhrase = "I'm a teapot"
376 , errReasonPhrase = "I'm a teapot"
375 , errBody = ""
377 , errBody = ""
376 , errHeaders = []
378 , errHeaders = []
@@ -383,8 +385,8 @@ err418 = ServantErr { errHTTPCode = 418
383-- > failingHandler :: Handler ()
385-- > failingHandler :: Handler ()
384-- > failingHandler = throwError $ err422 { errBody = "I understood your request, but can't process it." }
386-- > failingHandler = throwError $ err422 { errBody = "I understood your request, but can't process it." }
385--
387--
386−err422 :: ServantErr
388+err422 :: ServerError
387−err422 = ServantErr { errHTTPCode = 422
389+err422 = ServerError { errHTTPCode = 422
388 , errReasonPhrase = "Unprocessable Entity"
390 , errReasonPhrase = "Unprocessable Entity"
389 , errBody = ""
391 , errBody = ""
390 , errHeaders = []
392 , errHeaders = []
@@ -397,8 +399,8 @@ err422 = ServantErr { errHTTPCode = 422
397-- > failingHandler :: Handler ()
399-- > failingHandler :: Handler ()
398-- > failingHandler = throwError $ err500 { errBody = "Exception in module A.B.C:55. Have a great day!" }
400-- > failingHandler = throwError $ err500 { errBody = "Exception in module A.B.C:55. Have a great day!" }
399--
401--
400−err500 :: ServantErr
402+err500 :: ServerError
401−err500 = ServantErr { errHTTPCode = 500
403+err500 = ServerError { errHTTPCode = 500
402 , errReasonPhrase = "Internal Server Error"
404 , errReasonPhrase = "Internal Server Error"
403 , errBody = ""
405 , errBody = ""
404 , errHeaders = []
406 , errHeaders = []
@@ -411,8 +413,8 @@ err500 = ServantErr { errHTTPCode = 500
411-- > failingHandler :: Handler ()
413-- > failingHandler :: Handler ()
412-- > failingHandler = throwError $ err501 { errBody = "/v1/foo is not supported with quux in the request." }
414-- > failingHandler = throwError $ err501 { errBody = "/v1/foo is not supported with quux in the request." }
413--
415--
414−err501 :: ServantErr
416+err501 :: ServerError
415−err501 = ServantErr { errHTTPCode = 501
417+err501 = ServerError { errHTTPCode = 501
416 , errReasonPhrase = "Not Implemented"
418 , errReasonPhrase = "Not Implemented"
417 , errBody = ""
419 , errBody = ""
418 , errHeaders = []
420 , errHeaders = []
@@ -425,8 +427,8 @@ err501 = ServantErr { errHTTPCode = 501
425-- > failingHandler :: Handler ()
427-- > failingHandler :: Handler ()
426-- > failingHandler = throwError $ err502 { errBody = "Tried gateway foo, bar, and baz. None responded." }
428-- > failingHandler = throwError $ err502 { errBody = "Tried gateway foo, bar, and baz. None responded." }
427--
429--
428−err502 :: ServantErr
430+err502 :: ServerError
429−err502 = ServantErr { errHTTPCode = 502
431+err502 = ServerError { errHTTPCode = 502
430 , errReasonPhrase = "Bad Gateway"
432 , errReasonPhrase = "Bad Gateway"
431 , errBody = ""
433 , errBody = ""
432 , errHeaders = []
434 , errHeaders = []
@@ -439,8 +441,8 @@ err502 = ServantErr { errHTTPCode = 502
439-- > failingHandler :: Handler ()
441-- > failingHandler :: Handler ()
440-- > failingHandler = throwError $ err503 { errBody = "We're rewriting in PHP." }
442-- > failingHandler = throwError $ err503 { errBody = "We're rewriting in PHP." }
441--
443--
442−err503 :: ServantErr
444+err503 :: ServerError
443−err503 = ServantErr { errHTTPCode = 503
445+err503 = ServerError { errHTTPCode = 503
444 , errReasonPhrase = "Service Unavailable"
446 , errReasonPhrase = "Service Unavailable"
445 , errBody = ""
447 , errBody = ""
446 , errHeaders = []
448 , errHeaders = []
@@ -453,8 +455,8 @@ err503 = ServantErr { errHTTPCode = 503
453-- > failingHandler :: Handler ()
455-- > failingHandler :: Handler ()
454-- > failingHandler = throwError $ err504 { errBody = "Backend foobar did not respond in 5 seconds." }
456-- > failingHandler = throwError $ err504 { errBody = "Backend foobar did not respond in 5 seconds." }
455--
457--
456−err504 :: ServantErr
458+err504 :: ServerError
457−err504 = ServantErr { errHTTPCode = 504
459+err504 = ServerError { errHTTPCode = 504
458 , errReasonPhrase = "Gateway Time-out"
460 , errReasonPhrase = "Gateway Time-out"
459 , errBody = ""
461 , errBody = ""
460 , errHeaders = []
462 , errHeaders = []
@@ -467,8 +469,8 @@ err504 = ServantErr { errHTTPCode = 504
467-- > failingHandler :: Handler ()
469-- > failingHandler :: Handler ()
468-- > failingHandler = throwError $ err505 { errBody = "I support HTTP/4.0 only." }
470-- > failingHandler = throwError $ err505 { errBody = "I support HTTP/4.0 only." }
469--
471--
470−err505 :: ServantErr
472+err505 :: ServerError
471−err505 = ServantErr { errHTTPCode = 505
473+err505 = ServerError { errHTTPCode = 505
472 , errReasonPhrase = "HTTP Version not supported"
474 , errReasonPhrase = "HTTP Version not supported"
473 , errBody = ""
475 , errBody = ""
474 , errHeaders = []
476 , errHeaders = []