Skip to content

Commit

Permalink
Improve error handling in interceptor execution
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
koriym and coderabbitai[bot] authored Dec 8, 2024
1 parent 535b748 commit be7f484
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion rayaop.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,17 @@ static void rayaop_execute_ex(zend_execute_data *execute_data) {
ZVAL_STRING(&method_name, "intercept");

RAYAOP_G(is_intercepting) = 1;
if (call_user_function(NULL, &info->handler, &method_name, &retval, 3, params) == SUCCESS && !EG(exception)) {
int call_result = call_user_function(NULL, &info->handler, &method_name, &retval, 3, params);
if (call_result == SUCCESS && !EG(exception)) {
if (execute_data->return_value) {
if (!Z_ISUNDEF(retval)) {
ZVAL_COPY(execute_data->return_value, &retval); // Propagate explicit return values
} else {
ZVAL_NULL(execute_data->return_value); // Handle void or empty returns
}
}
} else if (call_result != SUCCESS) {
php_rayaop_handle_error(RAYAOP_E_INVALID_HANDLER, "Interceptor call failed");
}

cleanup:
Expand Down

0 comments on commit be7f484

Please sign in to comment.