From 8053534418cd1016c2f9182a009aefee406e1bfe Mon Sep 17 00:00:00 2001 From: JamesMallison Date: Sun, 10 May 2015 15:51:30 +0200 Subject: [PATCH] cURL errors now throw exceptions --- TwitterAPIExchange.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/TwitterAPIExchange.php b/TwitterAPIExchange.php index 71f8f59..5af6467 100755 --- a/TwitterAPIExchange.php +++ b/TwitterAPIExchange.php @@ -246,13 +246,13 @@ public function buildOauth($url, $requestMethod) */ public function performRequest($return = true) { - if (!is_bool($return)) - { - throw new Exception('performRequest parameter must be true or false'); + if (!is_bool($return)) + { + throw new Exception('performRequest parameter must be true or false'); } $header = array($this->buildAuthorizationHeader($this->oauth), 'Expect:'); - + $getfield = $this->getGetfield(); $postfields = $this->getPostfields(); @@ -279,6 +279,14 @@ public function performRequest($return = true) $feed = curl_init(); curl_setopt_array($feed, $options); $json = curl_exec($feed); + + if (($error = curl_error($feed)) !== '') + { + curl_close($feed); + + throw new \Exception($error); + } + curl_close($feed); return $json;