@@ -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)