Check for curl_exec failure and throw exception