Re: [RFC] Throwable Hierarchy Policy for Extensions

From: Date: Sun, 27 Apr 2025 21:45:02 +0000
Subject: Re: [RFC] Throwable Hierarchy Policy for Extensions
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Hi

On 4/27/25 23:16, Kamil Tekiela wrote:
The exception message MUST NOT be the only means of distinguishing exceptions. Any two exceptions with different messages MUST be identifiable either by a unique exception class name or code.
Thank you. I have used that as the basis for this change: https://github.com/php/policies/pull/17/files/7f7bb9bd09f3883bd13a70d7f61abbc62bfe04a1..dd507261a61cf088d07d9bdca80d91dcc54daf8a I've intentionally adjusted the wording to "different cause" rather than "different message" to avoid defining what constitutes a different message. As an example, when the CSPRNG fails, we might want to emit different error messages depending on the CSPRNG driver (e.g. /dev/urandom vs the getrandom() syscalls), but it's not useful to distinguish these cases with a different code, since the user does not decide which driver is used and can't do anything useful with that information. Even distinguishing between "/dev/urandom does not exist" and "/dev/urandom exists, but is a regular file instead of a character device" probably is only useful within the message itself, since neither is really recoverable from within PHP and allocating and documenting codes is likely work that helps no one. Best regards Tim Düsterhus

Thread (19 messages)

« previous php.internals (#127215) next »