@@ -48,13 +48,13 @@ data ServantError
48 { responseContentType :: MediaType
48 { responseContentType :: MediaType
49 , responseBody :: ByteString
49 , responseBody :: ByteString
52− { connectionError :: HttpException
54 | InvalidContentTypeHeader
51 | InvalidContentTypeHeader
55 { responseContentTypeHeader :: ByteString
52 { responseContentTypeHeader :: ByteString
56 , responseBody :: ByteString
53 , responseBody :: ByteString
56+ { connectionError :: SomeException
58 deriving (Show, Typeable)
58 deriving (Show, Typeable)
60instance Exception ServantError
60instance Exception ServantError
@@ -152,11 +152,11 @@ performRequest reqMethod req isWantedStatus reqHost = do
154 eResponse <- liftIO $ __withGlobalManager $ \ manager ->
154 eResponse <- liftIO $ __withGlobalManager $ \ manager ->
155− catchHttpException $
155+ catchConnectionError $
156− Client.httpLbs request manager
156+ Client.httpLbs request manager
157 case eResponse of
157 case eResponse of
158 Left err ->
158 Left err ->
159− left $ ConnectionError err
159+ left . ConnectionError $ SomeException err
161 Right response -> do
161 Right response -> do
162 let status = Client.responseStatus response
162 let status = Client.responseStatus response
@@ -189,6 +189,7 @@ performRequestNoBody reqMethod req wantedStatus reqHost = do
189 _ <- performRequest reqMethod req (`elem` wantedStatus) reqHost
189 _ <- performRequest reqMethod req (`elem` wantedStatus) reqHost
190 return ()
190 return ()
192−catchHttpException :: IO a -> IO (Either HttpException a)
192+catchConnectionError :: IO a -> IO (Either ServantError a)
193−catchHttpException action =
193+catchConnectionError action =
194− catch (Right <$> action) (pure . Left)
194+ catch (Right <$> action) $ \e ->
195+ pure . Left . ConnectionError $ SomeException (e :: HttpException)