From 911be50df29ea469fd07409e99df3675c764c7e5 Mon Sep 17 00:00:00 2001 From: Falco Peijnenburg Date: Sun, 8 Oct 2017 19:47:44 +0200 Subject: [PATCH] servant-client-ghcjs: Fixed not throwing FailureResponse --- .../src/Servant/Client/Internal/XhrClient.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/servant-client-ghcjs/src/Servant/Client/Internal/XhrClient.hs b/servant-client-ghcjs/src/Servant/Client/Internal/XhrClient.hs index 030aebf7..d1212a99 100644 --- a/servant-client-ghcjs/src/Servant/Client/Internal/XhrClient.hs +++ b/servant-client-ghcjs/src/Servant/Client/Internal/XhrClient.hs @@ -89,7 +89,13 @@ performRequest req = do xhr <- liftIO initXhr burl <- asks baseUrl liftIO $ performXhr xhr burl req - toResponse xhr + resp <- toResponse xhr + + let status = statusCode (responseStatusCode resp) + unless (status >= 200 && status < 300) $ + throwError $ FailureResponse resp + + pure resp -- * initialization