git.iko.soy/typeable/servant
on master help sign in
Merge pull request #119 from haskell-servant/existential-error

servant-client: Hide HttpException by wrapping it in SomeException

commit472249e92c4b94cd487a570b44baab2af1894686 authorChristian Marie <christian@ponies.io> dateWed 24 Jun 2015, 12:02 (11 years ago) parentad16c4fa4bf32c
2 files changed+3−8
servant-client/src/Servant/Common/Req.hs+3−3 servant-client/test/Servant/ClientSpec.hs−5
servant-client/src/Servant/Common/Req.hs+3−3
@@ -53,7 +53,7 @@ data ServantError
5353 , responseBody :: ByteString
5454 }
5555 | ConnectionError
56− { connectionError :: String
56+ { connectionError :: SomeException
5757 }
5858 deriving (Show, Typeable)
5959
@@ -156,7 +156,7 @@ performRequest reqMethod req isWantedStatus reqHost = do
156156 Client.httpLbs request manager
157157 case eResponse of
158158 Left err ->
159− left $ ConnectionError (show err)
159+ left . ConnectionError $ SomeException err
160160
161161 Right response -> do
162162 let status = Client.responseStatus response
@@ -192,4 +192,4 @@ performRequestNoBody reqMethod req wantedStatus reqHost = do
192192catchConnectionError :: IO a -> IO (Either ServantError a)
193193catchConnectionError action =
194194 catch (Right <$> action) $ \e ->
195− pure . Left . ConnectionError . show $ (e :: HttpException)
195+ pure . Left . ConnectionError $ SomeException (e :: HttpException)
servant-client/test/Servant/ClientSpec.hs−5
@@ -68,11 +68,6 @@ instance FromFormUrlEncoded Person where
6868 a <- lookupEither "age" xs
6969 return $ Person (T.unpack n) (read $ T.unpack a)
7070
71−deriving instance Eq ServantError
72−
73−instance Eq C.HttpException where
74− a == b = show a == show b
75−
7671alice :: Person
7772alice = Person "Alice" 42
7873