8000 Document exception chaining by greg0ire · Pull Request #3855 · php/doc-en · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Document exception chaining #3855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 23, 2025
Merged

Conversation

greg0ire
Copy link
Contributor
@greg0ire greg0ire commented Oct 11, 2024

This is already documented as a user note, but the note does not explain what happens if both exceptions already have a previous exception.

Here is what I believe is the related piece of code:

/* Chain potential exception from wrapping finally block */
if (Z_OBJ_P(fast_call)) {
	if (ex) {
		if (zend_is_unwind_exit(ex) || zend_is_graceful_exit(ex)) {
			/* discard the previously thrown exception */
			OBJ_RELEASE(Z_OBJ_P(fast_call));
		} else {
			zend_exception_set_previous(ex, Z_OBJ_P(fast_call));
		}
	} else {
		ex = EG(exception) = Z_OBJ_P(fast_call);
	}
}

This is already documented as a user note, but the note does not explain
what happens if both exceptions already have a previous exception.

Here is what I believe is the related piece of code:

/* Chain potential exception from wrapping finally block */
if (Z_OBJ_P(fast_call)) {
	if (ex) {
		if (zend_is_unwind_exit(ex) || zend_is_graceful_exit(ex)) {
			/* discard the previously thrown exception */
			OBJ_RELEASE(Z_OBJ_P(fast_call));
		} else {
			zend_exception_set_previous(ex, Z_OBJ_P(fast_call));
		}
	} else {
		ex = EG(exception) = Z_OBJ_P(fast_call);
	}
}

The note: https://www.php.net/manual/en/language.exceptions.php#129177
Copy link
Member
@jimwins jimwins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@DanielEScherzer
Copy link
Member
8000

Sorry it took us so long to merge this; thank you for your contribution!

@DanielEScherzer DanielEScherzer merged commit ed956d7 into php:master Jun 23, 2025
2 checks passed
@greg0ire greg0ire deleted the 2-exceptions branch June 24, 2025 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0