HTTP icon indicating copy to clipboard operation
HTTP copied to clipboard

simpleHTTP raises exception on connection refused

Open wahjava opened this issue 9 years ago • 1 comments

When nothing listening on localhost:81, with following code:

(simpleHTTP (getRequest "http://localhost:81/")) >>= (\r -> case r of Left _ -> putStrLn "Error"; Right _ -> putStrLn "Alright!")

instead of printing Error, I get:

*** Exception: connect: does not exist (Connection refused)

To me, and as suggested by someone in #haskell, this seems like an unexpected behaviour. I'm expecting error condition to be passed in return value.

Thanks!

wahjava avatar Nov 16 '15 03:11 wahjava

With pull request #102 the behaviour changes to:

λ> import Network.HTTP
λ> Network.HTTP.simpleHTTP (getRequest "http://localhost:81")
Left (ErrorMisc "connect: does not exist (Connection refused)")

oherrala avatar Jun 05 '16 20:06 oherrala