-extern void _http_request_pool_responsehandler(zval **req TSRMLS_DC);
-#define http_request_pool_requesthandler(r, b) _http_request_pool_requesthandler((r), (b) TSRMLS_CC)
-extern STATUS _http_request_pool_requesthandler(zval *request, http_request_body *body TSRMLS_DC);
+extern void _http_request_pool_responsehandler(zval **req, CURL *ch TSRMLS_DC);
+
+#define http_request_pool_try \
+ { \
+ zval *old_exception = EG(exception); \
+ EG(exception) = NULL;
+#define http_request_pool_catch() \
+ if (EG(exception)) { \
+ http_request_pool_wrap_exception(old_exception, EG(exception)); \
+ } else { \
+ EG(exception) = old_exception; \
+ } \
+ }
+#define http_request_pool_final() \
+ if (EG(exception)) { \
+ zval *exception; \
+ http_request_pool_wrap_exception(NULL, EG(exception)); \
+ exception = EG(exception); \
+ EG(exception) = NULL; \
+ zend_throw_exception_object(exception TSRMLS_CC); \
+ }
+
+#define http_request_pool_wrap_exception(o, n) _http_request_pool_wrap_exception((o), (n) TSRMLS_CC)
+extern void _http_request_pool_wrap_exception(zval *old_exception, zval *new_exception TSRMLS_DC);
+