servant-checked-exceptions 2.2.0.0 → 2.2.0.1
raw patch · 6 files changed
+42/−21 lines, 6 filesdep +hspecPVP ok
version bump matches the API change (PVP)
Dependencies added: hspec
API changes (from Hackage documentation)
Files
- CHANGELOG.md +13/−8
- README.md +15/−7
- example/Api.hs +6/−0
- example/Client.hs +3/−3
- servant-checked-exceptions.cabal +3/−2
- test/Spec.hs +2/−1
CHANGELOG.md view
@@ -1,19 +1,24 @@++## 2.2.0.1++* Fix small import problem in the tests. [#38](https://github.com/cdepillabout/servant-checked-exceptions/pull/38)+ ## 2.2.0.0 -* Add the `EnvelopeT` monad transformer. [#32]+* Add the `EnvelopeT` monad transformer. [#32](https://github.com/cdepillabout/servant-checked-exceptions/pull/32) * Add a few combinators for `Envelope`: - - `envelopeRemove`- - `envelopeHandle`- - `relaxEnvelope`- - `liftA2Envelope`- - `bindEnvelope`+ - `envelopeRemove`+ - `envelopeHandle`+ - `relaxEnvelope`+ - `liftA2Envelope`+ - `bindEnvelope` - [#32]+ [#32](https://github.com/cdepillabout/servant-checked-exceptions/pull/32) * Add an example of using `EnvelopeT` in- `servant-checked-exceptions/example/EnvelopeT.hs`. [#32]+ `servant-checked-exceptions/example/EnvelopeT.hs`. [#32](https://github.com/cdepillabout/servant-checked-exceptions/pull/32) ## 2.1.0.0
README.md view
@@ -2,7 +2,7 @@ Servant.Checked.Exceptions ========================== -[](http://travis-ci.org/cdepillabout/servant-checked-exceptions)+[](https://github.com/cdepillabout/servant-checked-exceptions) [](https://hackage.haskell.org/package/servant-checked-exceptions) [](http://stackage.org/lts/package/servant-checked-exceptions) [](http://stackage.org/nightly/package/servant-checked-exceptions)@@ -87,10 +87,10 @@ ## Example -This repository contains an [example](example/) of using-`servant-checked-exceptions`. This includes an [api](example/Api.hs),-[server](example/Server.hs), [client](example/Client.hs), and-[documentation](example/Docs.hs).+This repository contains an [example](servant-checked-exceptions/example/) of using+`servant-checked-exceptions`. This includes an [api](servant-checked-exceptions/example/Api.hs),+[server](servant-checked-exceptions/example/Server.hs), [client](servant-checked-exceptions/example/Client.hs), and+[documentation](servant-checked-exceptions-core/example/Docs.hs). Below I show how to compile and run these examples. @@ -99,7 +99,7 @@ The examples can be compiled by using the `buildexample` flag: ```sh-$ stack build --flag servant-checked-exceptions:buildexample+$ stack build --flag servant-checked-exceptions-core:buildexample --flag servant-checked-exceptions:buildexample ``` This creates three executables. A server, a client, and a documentaiton@@ -178,7 +178,7 @@ The documentation generator will generate documentation for the api in Markdown: ```sh-$ stack exec -- servant-checked-exceptions-example-docs+$ stack exec -- servant-checked-exceptions-core-example-docs ``` Here is a small example of the documentation that will be generated for the lax@@ -219,6 +219,14 @@ and `servant-server`. This can be useful if you are writing an API meant to be shared with ghcjs and run in a browser, where these dependencies aren't available.++## Limitations++Currently, `servant-client` only treats HTTP responses as successful if they+have a status code of 2XX. This means that any non-2XX errors thrown by+`servant-checked-exceptions` don't get parsed into a typed `Envelope` as+expected, but raised as a Servant `ClientError`. For more information, see+[issue #27](https://github.com/cdepillabout/servant-checked-exceptions/issues/27). ## Maintainers
example/Api.hs view
@@ -109,6 +109,9 @@ parseJSON = withText "BadSearchTermErr" $ maybe (fail "could not parse as BadSearchTermErr") pure . readMaybe . unpack +-- | Note that clients generated by @servant-client@ currently don't handle+-- status codes outside the @2XX@ range correctly.+-- Take a look at the README for more details. instance ErrStatus BadSearchTermErr where toErrStatus :: BadSearchTermErr -> Status toErrStatus _ = status404@@ -128,6 +131,9 @@ parseJSON = withText "IncorrectCapitalization" $ maybe (fail "could not parse as IncorrectCapitalization") pure . readMaybe . unpack +-- | Note that clients generated by @servant-client@ currently don't handle+-- status codes outside the @2XX@ range correctly.+-- Take a look at the README for more details. instance ErrStatus IncorrectCapitalization where toErrStatus :: IncorrectCapitalization -> Status toErrStatus _ = status400
example/Client.hs view
@@ -25,8 +25,8 @@ metavar, progDesc, short, str, switch) import Servant.API ((:<|>)((:<|>))) import Servant.Client- (BaseUrl(BaseUrl), ClientEnv(ClientEnv), ClientM, Scheme(Http),- client, runClientM)+ (BaseUrl(BaseUrl), ClientEnv, ClientM, Scheme(Http),+ client, mkClientEnv, runClientM) import Servant.Checked.Exceptions (Envelope, emptyEnvelope, catchesEnvelope) @@ -142,7 +142,7 @@ main :: IO () main = do manager <- newManager defaultManagerSettings- let clientEnv = ClientEnv manager baseUrl Nothing+ let clientEnv = mkClientEnv manager baseUrl options <- execParser opts run clientEnv options where
servant-checked-exceptions.cabal view
@@ -1,5 +1,5 @@ name: servant-checked-exceptions-version: 2.2.0.0+version: 2.2.0.1 synopsis: Checked exceptions for Servant APIs. description: Please see <https://github.com/cdepillabout/servant-checked-exceptions#readme README.md>. homepage: https://github.com/cdepillabout/servant-checked-exceptions@@ -7,7 +7,7 @@ license-file: LICENSE author: Dennis Gosnell maintainer: cdep.illabout@gmail.com-copyright: 2017-2018 Dennis Gosnell+copyright: 2017-2021 Dennis Gosnell category: Web build-type: Simple extra-source-files: CHANGELOG.md@@ -113,6 +113,7 @@ other-modules: hs-source-dirs: test build-depends: base+ , hspec , hspec-wai , http-types , tasty
test/Spec.hs view
@@ -23,6 +23,7 @@ , ServerT , serve )+import Test.Hspec (describe, it) import Test.Hspec.Wai ( ResponseMatcher(matchStatus) , get@@ -30,7 +31,7 @@ , with ) import Test.Tasty (TestTree, defaultMain, testGroup)-import Test.Tasty.Hspec (describe, it, testSpec)+import Test.Tasty.Hspec (testSpec) import Test.Tasty.HUnit ((@?=), assertFailure, testCase) import Servant.Checked.Exceptions