throw error if cURL failed