From c3ed5d97ba0f91010327f20eba41d7e07f5f243e Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Wed, 30 Dec 2009 12:38:03 +0000 Subject: [PATCH] add curlCode property to HttpRequestException --- http_exception_object.c | 3 +++ http_request_api.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/http_exception_object.c b/http_exception_object.c index 2de284e..b26539f 100644 --- a/http_exception_object.c +++ b/http_exception_object.c @@ -76,6 +76,9 @@ PHP_MINIT_FUNCTION(http_exception_object) HTTP_REGISTER_EXCEPTION(HttpMessageTypeException, HTTP_EX_CE(message_type), HTTP_EX_DEF_CE); HTTP_REGISTER_EXCEPTION(HttpEncodingException, HTTP_EX_CE(encoding), HTTP_EX_DEF_CE); HTTP_REGISTER_EXCEPTION(HttpRequestException, HTTP_EX_CE(request), HTTP_EX_DEF_CE); + + zend_declare_property_long(HTTP_EX_CE(request), "curlCode", lenof("curlCode"), 0, ZEND_ACC_PUBLIC TSRMLS_CC); + HTTP_REGISTER_EXCEPTION(HttpRequestPoolException, HTTP_EX_CE(request_pool), HTTP_EX_DEF_CE); HTTP_REGISTER_EXCEPTION(HttpSocketException, HTTP_EX_CE(socket), HTTP_EX_DEF_CE); HTTP_REGISTER_EXCEPTION(HttpResponseException, HTTP_EX_CE(response), HTTP_EX_DEF_CE); diff --git a/http_request_api.c b/http_request_api.c index d2440b7..292c1ee 100644 --- a/http_request_api.c +++ b/http_request_api.c @@ -1085,6 +1085,11 @@ PHP_HTTP_API void _http_request_exec(http_request *request) retry: if (CURLE_OK != (result = curl_easy_perform(request->ch))) { http_error_ex(HE_WARNING, HTTP_E_REQUEST, "%s; %s (%s)", curl_easy_strerror(result), http_request_storage_get(request->ch)->errorbuffer, request->url); +#ifdef ZEND_ENGINE_2 + if ((HTTP_G->only_exceptions || GLOBAL_ERROR_HANDLING == EH_THROW) && EG(exception)) { + add_property_long(EG(exception), "curlCode", result); + } +#endif if (request->_retry.count > tries++) { switch (result) { -- 2.30.2