throw exception for invalid URL response from curl

I can see you have added the exception handler already but just in case you still want it. I tidied up the test and renamed it since your original comment, all looks much neater now. This version also includes the curl error details too, could be useful.