From 21962f522aefc943c0d69e08b0d5d76c23a0de61 Mon Sep 17 00:00:00 2001 From: Lucky Soni Date: Wed, 5 Nov 2014 00:54:38 +0530 Subject: [PATCH] Throw exception with actual CURL error Instead of throwing a generic "cURL call failed" error, lets send along the actual error details so that the consumer can debug easily. --- lib/Twocheckout/Api/TwocheckoutApi.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Twocheckout/Api/TwocheckoutApi.php b/lib/Twocheckout/Api/TwocheckoutApi.php index 27d3431..52e5465 100755 --- a/lib/Twocheckout/Api/TwocheckoutApi.php +++ b/lib/Twocheckout/Api/TwocheckoutApi.php @@ -44,9 +44,13 @@ function doCall($urlSuffix, $data=array()) curl_setopt($ch, CURLOPT_USERAGENT, "2Checkout PHP/0.1.0%s"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $resp = curl_exec($ch); + if ($resp === FALSE) { + $c_err = curl_error($ch); + $c_err_no = curl_errno($ch); + } curl_close($ch); if ($resp === FALSE) { - throw new Twocheckout_Error("cURL call failed", "403"); + throw new Twocheckout_Error($c_err, $c_err_no); } else { return utf8_encode($resp); }