Req #80165 [Com]: set_exception_handler() should return false on error

From: Date: Thu, 01 Oct 2020 08:15:16 +0000
Subject: Req #80165 [Com]: set_exception_handler() should return false on error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229293@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80165&edit=1

 ID:                 80165
 Comment by:         divinity76 at gmail dot com
 Reported by:        divinity76 at gmail dot com
 Summary:            set_exception_handler() should return false on error
 Status:             Feedback
 Type:               Feature/Change Request
 Package:            Scripting Engine problem
 PHP Version:        Next Major Version
 Block user comment: N
 Private report:     N

 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------
[2020-10-01 08:02:45] 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:00:13] 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)



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=80165&edit=1


Thread (4 messages)

« previous php.bugs (#229293) next »