Skip to content

Commit

Permalink
add error numbers, #17
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkgroenen committed Dec 31, 2015
1 parent 5f76103 commit e6461e8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Pinterest/Transport/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,15 @@ public function execute( $method, $apiCall, array $parameters = array(), $header

// Check if we have a valid response
if ( !$response_data || $ch->hasErrors() ) {
throw new PinterestException( 'Error: execute() - cURL error: ' . $ch->getErrors() );
throw new PinterestException( 'Error: execute() - cURL error: ' . $ch->getErrors(), $ch->getErrorNumber() );
}

// Initiate the response
$response = new Response($response_data, $ch);

// Check the response code
if ( $response->getResponseCode() >= 400 ) {
throw new PinterestException( 'Pinterest error (code: ' . $response->getResponseCode() . ') with message: ' . $response->message );
throw new PinterestException( 'Pinterest error (code: ' . $response->getResponseCode() . ') with message: ' . $response->message, $response->getResponseCode() );
}

// Close curl resource
Expand Down
12 changes: 12 additions & 0 deletions src/Pinterest/Utils/CurlBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ public function getErrors()
return curl_error($this->curl);
}

/**
* Get last curl error number
*
* @access public
* @return int
*/
public function getErrorNumber()
{
return curl_errno($this->curl);
}


/**
* Get curl info key
*
Expand Down

0 comments on commit e6461e8

Please sign in to comment.