Skip to content

add get_error_handler() and get_exception_handler() #969

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

Closed
wants to merge 3 commits into from

Conversation

Tyrael
Copy link
Contributor

@Tyrael Tyrael commented Dec 30, 2014

Sometimes it is useful to get the current error/exception handler without replacing it (which is already possible with set__handler and restore__handler albeit a a bit more work).
Merging this PR would also resolve https://bugs.php.net/bug.php?id=54033

/* {{{ proto string get_error_handler(void)
Returns the currently defined error handler, or null */
ZEND_FUNCTION(get_error_handler)
{
Copy link
Member

Choose a reason for hiding this comment

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

Here and in get_exception_handler(), you should use zend_parse_parameters_none(), else the changes look great!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hehe, nice catch, was copying most of the code from restore_error_handler() and surprisingly zend_parse_parameters_none() is not used there.

Copy link
Member

Choose a reason for hiding this comment

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

@Kubo2
Copy link
Contributor

Kubo2 commented Apr 11, 2015

@Tyrael 👍

@bwoebi
Copy link
Member

bwoebi commented Oct 7, 2015

I'd propose setting the return_value of restore_error/exception_handler to the removed handler. That already should cover most use cases… and if that's not what you need, restore and set.
Also keeps the list of functions tidier :-)

@Tyrael
Copy link
Contributor Author

Tyrael commented Oct 7, 2015

what would restore_error/exception_handler() return when there is no user handler set?
to match the behavior of set_error/exception_handler() that would require returning NULL which contradicts the current documentation that restore_error/exception_handler() always returns TRUE.
I'm not sure that it would worth changing that assuming that the next version after 7.0 will be a minor.

@bwoebi
Copy link
Member

bwoebi commented Oct 7, 2015

Actually, I think we relatively safely can assume the return value of restore_error/exception_handler() isn't used much currently.

And yes, NULL would be a sensible return value then.

@krakjoe
Copy link
Member

krakjoe commented Jan 3, 2017

@Tyrael can we know the current status of this PR please ?

@krakjoe
Copy link
Member

krakjoe commented Feb 3, 2017

Having waited a month for feedback, and since there seems to be some unresolved questions, I'm closing this PR.

Please take this action as encouragement to open a clean PR against a supported branch.

@Tyrael
Copy link
Contributor Author

Tyrael commented Feb 3, 2017

@krakjoe was mostly just waiting for other's to join the discussion, gather more feedback, but maybe the lack of responses mean that this is not something which many people needs.

@jleaders
Copy link

jleaders commented Dec 5, 2018

I would use this 👍 +1 from me. Right now I have found some 3rd party library has changed my exception handler and I have no idea which one, and querying for the handler would expose the culprit library! Can at the very least, a workaround be published in the set_exception_handler() docs?
But I'd like to see a get_ or a return on set_/restore_

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants