Skip to content

Commit f1e2792

Browse files
committed
Merge pull request abraham#339 from patricknelson/curl-exceptions
FIX: Address issue abraham#338 and throw an exception on all cURL errors.
2 parents 820de59 + e034ff4 commit f1e2792

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/TwitterOAuth.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -323,17 +323,9 @@ private function request($url, $method, $authorization, $postfields)
323323
curl_setopt_array($curlHandle, $options);
324324
$response = curl_exec($curlHandle);
325325

326+
// Throw exceptions on cURL errors.
326327
$curlErrno = curl_errno($curlHandle);
327-
switch ($curlErrno) {
328-
case 28:
329-
throw new TwitterOAuthException('Request timed out.');
330-
case 51:
331-
throw new TwitterOAuthException('The remote servers SSL certificate or SSH md5 fingerprint failed validation.');
332-
case 56:
333-
throw new TwitterOAuthException('Response from server failed or was interrupted.');
334-
case 77:
335-
throw new TwitterOAuthException('Problem with the SSL CA cert (path? access rights?)');
336-
}
328+
if ($curlErrno > 0) throw new TwitterOAuthException(curl_error($curlHandle), $curlErrno);
337329

338330
$this->response->setHttpCode(curl_getinfo($curlHandle, CURLINFO_HTTP_CODE));
339331
$parts = explode("\r\n\r\n", $response);

0 commit comments

Comments
 (0)