git.iko.soy/typeable/servant
on master help sign in
Merge pull request #119 from haskell-servant/existential-error
472249eChristian Marie
servant-client/src/Servant/Common/Req.hs+3−3
@@ -53,7 +53,7 @@ data ServantError
53 , responseBody :: ByteString
53 , responseBody :: ByteString
54 }
54 }
55 | ConnectionError
55 | ConnectionError
56− { connectionError :: String
56+ { connectionError :: SomeException
57 }
57 }
58 deriving (Show, Typeable)
58 deriving (Show, Typeable)
59
59
@@ -156,7 +156,7 @@ performRequest reqMethod req isWantedStatus reqHost = do
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 (show err)
159+ left . ConnectionError $ SomeException err
160
160
161 Right response -> do
161 Right response -> do
162 let status = Client.responseStatus response
162 let status = Client.responseStatus response
@@ -192,4 +192,4 @@ performRequestNoBody reqMethod req wantedStatus reqHost = do
192catchConnectionError :: IO a -> IO (Either ServantError a)
192catchConnectionError :: IO a -> IO (Either ServantError a)
193catchConnectionError action =
193catchConnectionError action =
194 catch (Right <$> action) $ \e ->
194 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
68 a <- lookupEither "age" xs
68 a <- lookupEither "age" xs
69 return $ Person (T.unpack n) (read $ T.unpack a)
69 return $ Person (T.unpack n) (read $ T.unpack a)
70
70
71−deriving instance Eq ServantError
72−
73−instance Eq C.HttpException where
74− a == b = show a == show b
75−
76alice :: Person
71alice :: Person
77alice = Person "Alice" 42
72alice = Person "Alice" 42
78
73