git.iko.soy/typeable/servant
on master help sign in
Don't export HttpException
commited7d235b260a6d04a17a417b453e641c063cacea authorTimo von Holtz <tvh@anchor.com.au> dateMon 25 May 2015, 17:51 (11 years ago) parent5c25c56
2 files changed+11−10
servant-client/src/Servant/Common/Req.hs+10−9 servant-client/test/Servant/ClientSpec.hs+1−1
servant-client/src/Servant/Common/Req.hs+10−9
@@ -46,13 +46,13 @@ data ServantError
4646 { responseContentType :: MediaType
4747 , responseBody :: ByteString
4848 }
49− | ConnectionError
50− { connectionError :: HttpException
51− }
5249 | InvalidContentTypeHeader
5350 { responseContentTypeHeader :: ByteString
5451 , responseBody :: ByteString
5552 }
53+ | ConnectionError
54+ { connectionError :: String
55+ }
5656 deriving (Show)
5757
5858data Req = Req
@@ -148,11 +148,11 @@ performRequest reqMethod req isWantedStatus reqHost = do
148148 }
149149
150150 eResponse <- liftIO $ __withGlobalManager $ \ manager ->
151− catchHttpException $
152− Client.httpLbs request manager
151+ catchConnectionError $
152+ Client.httpLbs request manager
153153 case eResponse of
154154 Left err ->
155− left $ ConnectionError err
155+ left $ ConnectionError (show err)
156156
157157 Right response -> do
158158 let status = Client.responseStatus response
@@ -185,6 +185,7 @@ performRequestNoBody reqMethod req wantedStatus reqHost = do
185185 _ <- performRequest reqMethod req (`elem` wantedStatus) reqHost
186186 return ()
187187
188−catchHttpException :: IO a -> IO (Either HttpException a)
189−catchHttpException action =
190− catch (Right <$> action) (pure . Left)
188+catchConnectionError :: IO a -> IO (Either ServantError a)
189+catchConnectionError action =
190+ catch (Right <$> action) $ \e ->
191+ pure . Left . ConnectionError . show $ (e :: HttpException)
servant-client/test/Servant/ClientSpec.hs+1−1
@@ -303,7 +303,7 @@ failSpec = withFailServer $ \ baseUrl -> do
303303 it "reports ConnectionError" $ do
304304 Left res <- runEitherT getGetWrongHost
305305 case res of
306− ConnectionError (C.FailedConnectionException2 "127.0.0.1" 19872 False _) -> return ()
306+ ConnectionError _ -> return ()
307307 _ -> fail $ "expected ConnectionError, but got " <> show res
308308
309309 it "reports UnsupportedContentType" $ do