From 29c9d85adece5aeabde9328e38d49d8eb3d4b2e4 Mon Sep 17 00:00:00 2001 From: Stevan Andjelkovic Date: Fri, 5 May 2017 17:05:55 +0200 Subject: [PATCH] Use BaseUrl and Req instead of Request. --- servant-client/src/Servant/Common/Req.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/servant-client/src/Servant/Common/Req.hs b/servant-client/src/Servant/Common/Req.hs index 462c5d1e..4cbb3fc9 100644 --- a/servant-client/src/Servant/Common/Req.hs +++ b/servant-client/src/Servant/Common/Req.hs @@ -48,7 +48,7 @@ import Web.HttpApiData data ServantError = FailureResponse - { failingRequest :: Request + { failingRequest :: UrlReq , responseStatus :: Status , responseContentType :: MediaType , responseBody :: ByteString @@ -86,6 +86,11 @@ instance Eq ServantError where instance Exception ServantError +data UrlReq = UrlReq BaseUrl Req + +instance Show UrlReq where + show (UrlReq url req) = showBaseUrl url ++ reqPath req ++ "?" ++ show (qs req) + data Req = Req { reqPath :: String , qs :: QueryText @@ -251,7 +256,7 @@ performRequest reqMethod req = do Nothing -> throwError $ InvalidContentTypeHeader (cs t) body Just t' -> pure t' unless (status_code >= 200 && status_code < 300) $ - throwError $ FailureResponse request status ct body + throwError $ FailureResponse (UrlReq reqHost req) status ct body return (status_code, body, ct, hdrs, response) performRequestCT :: MimeUnrender ct result => Proxy ct -> Method -> Req