Skip to content

Commit be7f484

Browse files
Improve error handling in interceptor execution
Add explicit error handling when interceptor call fails but doesn't raise an exception. The change separates error conditions between call failure and exceptions, providing more detailed error reporting through php_rayaop_handle_error. - Split call_user_function result check into separate variable - Add specific error handling for call failures - Report errors with RAYAOP_E_INVALID_HANDLER code Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 535b748 commit be7f484

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

rayaop.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,17 @@ static void rayaop_execute_ex(zend_execute_data *execute_data) {
234234
ZVAL_STRING(&method_name, "intercept");
235235

236236
RAYAOP_G(is_intercepting) = 1;
237-
if (call_user_function(NULL, &info->handler, &method_name, &retval, 3, params) == SUCCESS && !EG(exception)) {
237+
int call_result = call_user_function(NULL, &info->handler, &method_name, &retval, 3, params);
238+
if (call_result == SUCCESS && !EG(exception)) {
238239
if (execute_data->return_value) {
239240
if (!Z_ISUNDEF(retval)) {
240241
ZVAL_COPY(execute_data->return_value, &retval); // Propagate explicit return values
241242
} else {
242243
ZVAL_NULL(execute_data->return_value); // Handle void or empty returns
243244
}
244245
}
246+
} else if (call_result != SUCCESS) {
247+
php_rayaop_handle_error(RAYAOP_E_INVALID_HANDLER, "Interceptor call failed");
245248
}
246249

247250
cleanup:

0 commit comments

Comments
 (0)