php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #80165 set_exception_handler() should return false on error
Submitted: 2020-10-01 08:00 UTC Modified: 2020-10-01 08:16 UTC
From: divinity76 at gmail dot com Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: Next Major Version OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2020-10-01 08:00 UTC] divinity76 at gmail dot com
Description:
------------
currently set_exception_handler() returns null on error, and null|callable on success. 

so when it does return null, there's no good way to tell "did it return null because of an error, or did it return null because of success-but-there-was-no-previous-handler ?"

.. i think it would be an improvement if it returned bool(false) on error and null|callable on success, then it would cleanly separate error-returns from success-returns. i guess that's a BC-break and should go in the next major version though (for scripts knowing full well that there's a previous handler and looking for nulls to detect errors? idk if that even exist, but i guess it might)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-10-01 08:02 UTC] requinix@php.net
-Status: Open +Status: Feedback -Package: Unknown/Other Function +Package: Scripting Engine problem
 [2020-10-01 08:02 UTC] requinix@php.net
In PHP 8, set_exception_handler throws a TypeError for a bad callback argument. It still returns null if successful and there was no previous handler.
 [2020-10-01 08:15 UTC] divinity76 at gmail dot com
oh nice, so it seems PHP8 throws on error, and returns null|callable on success, that's even better, thanks,

nevermind then, this request can be closed.
 [2020-10-01 08:16 UTC] requinix@php.net
-Status: Feedback +Status: Wont fix
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Nov 23 20:01:23 2020 UTC