[RFC] Add get_error_handler(), get_exception_handler() functions

php.internals

Arnaud.lb

1 year ago
Hi, At the moment, there is no direct way to fetch the currently registered error or exception handlers. Users who need to inspect these handlers must resort to a workaround that temporarily sets a new handler and then immediately restores the previous one: $current_error_handler = set_error_handler('valid_callback'); restore_error_handler(); This feels hackish and is error-prone. I would like to propose the addition of two new functions: get_error_handler(), get_exception_handler() to address this: https://wiki.php.net/rfc/get-error-exception-handler Best Regards, Arnaud

Jordi Boggiano

1 year ago
On 11.02.2025 14:18, Arnaud Le Blanc wrote:
> At the moment, there is no direct way to fetch the currently > registered error or exception handlers. Users who need to inspect > these handlers must resort to a workaround that temporarily sets a new > handler and then immediately restores the previous one: > > $current_error_handler = set_error_handler('valid_callback'); > restore_error_handler(); > > This feels hackish and is error-prone.
Sounds good to me, straightforward clean-up of a weird API. Best, Jordi
-- Jordi Boggiano @seldaek - https://seld.be