diff --git a/src/Pinterest/Transport/Request.php b/src/Pinterest/Transport/Request.php index c0d43e2..a0621d1 100644 --- a/src/Pinterest/Transport/Request.php +++ b/src/Pinterest/Transport/Request.php @@ -181,7 +181,7 @@ 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 @@ -189,7 +189,7 @@ public function execute( $method, $apiCall, array $parameters = array(), $header // 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 diff --git a/src/Pinterest/Utils/CurlBuilder.php b/src/Pinterest/Utils/CurlBuilder.php index 6481371..43b9418 100644 --- a/src/Pinterest/Utils/CurlBuilder.php +++ b/src/Pinterest/Utils/CurlBuilder.php @@ -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 *