@@ -46,13 +46,13 @@ data ServantError
46 { responseContentType :: MediaType
46 { responseContentType :: MediaType
47 , responseBody :: ByteString
47 , responseBody :: ByteString
50− { connectionError :: HttpException
52 | InvalidContentTypeHeader
49 | InvalidContentTypeHeader
53 { responseContentTypeHeader :: ByteString
50 { responseContentTypeHeader :: ByteString
54 , responseBody :: ByteString
51 , responseBody :: ByteString
54+ { connectionError :: String
56 deriving (Show)
56 deriving (Show)
58data Req = Req
58data Req = Req
@@ -148,11 +148,11 @@ performRequest reqMethod req isWantedStatus reqHost = do
150 eResponse <- liftIO $ __withGlobalManager $ \ manager ->
150 eResponse <- liftIO $ __withGlobalManager $ \ manager ->
151− catchHttpException $
151+ catchConnectionError $
152− Client.httpLbs request manager
152+ Client.httpLbs request manager
153 case eResponse of
153 case eResponse of
154 Left err ->
154 Left err ->
155− left $ ConnectionError err
155+ left $ ConnectionError (show err)
157 Right response -> do
157 Right response -> do
158 let status = Client.responseStatus response
158 let status = Client.responseStatus response
@@ -185,6 +185,7 @@ performRequestNoBody reqMethod req wantedStatus reqHost = do
185 _ <- performRequest reqMethod req (`elem` wantedStatus) reqHost
185 _ <- performRequest reqMethod req (`elem` wantedStatus) reqHost
186 return ()
186 return ()
188−catchHttpException :: IO a -> IO (Either HttpException a)
188+catchConnectionError :: IO a -> IO (Either ServantError a)
189−catchHttpException action =
189+catchConnectionError action =
190− catch (Right <$> action) (pure . Left)
190+ catch (Right <$> action) $ \e ->
191+ pure . Left . ConnectionError . show $ (e :: HttpException)