Skip to content

Commit

Permalink
suggestion fix for issue #45
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkgroenen committed May 6, 2016
1 parent 17a2df0 commit 14dca31
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/Pinterest/Exceptions/CurlException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
/**
* Copyright 2015 Dirk Groenen
*
* (c) Dirk Groenen <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace DirkGroenen\Pinterest\Exceptions;

class CurlException extends \Exception {

}
7 changes: 5 additions & 2 deletions src/Pinterest/Transport/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use DirkGroenen\Pinterest\Utils\CurlBuilder;
use DirkGroenen\Pinterest\Exceptions\PinterestException;
use DirkGroenen\Pinterest\Exceptions\CurlException;

class Request {

Expand Down Expand Up @@ -211,8 +212,10 @@ public function execute($method, $apiCall, array $parameters = array(), $headers
// Execute request and catch response
$response_data = $ch->execute();

// Check if we have a valid response
if (!$response_data || $ch->hasErrors()) {
if ($response_data === false && !$ch->hasErrors()) {
throw new CurlException("Error: Curl request failed")
}
else if($ch->hasErrors()) {
throw new PinterestException('Error: execute() - cURL error: ' . $ch->getErrors(), $ch->getErrorNumber());
}

Expand Down

0 comments on commit 14dca31

Please sign in to comment.