Re: [RFC] Throwable Hierarchy Policy for Extensions

From: Date: Mon, 28 Apr 2025 22:56:33 +0000
Subject: Re: [RFC] Throwable Hierarchy Policy for Extensions
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Hi

On 4/29/25 00:36, Larry Garfield wrote:
It's a common recommendation in userland, as it allows implementers to extend an existing exception (eg, InvalidArgumentException) of their choice while still being tagged as coming from a given library. Though I suppose if the policy doc also says to never do that, that becomes an irrelevant consideration.
Yes, the SPL exceptions are so awfully generic that there is no value in catching them, since they can refer to *anything*. And when you can't usefully catch them, then extending them doesn't make sense either. And a TypeError or ValueError is a clear programming error (failure to check preconditions), so that it also is incorrect to catch them. Best regards Tim Düsterhus

Thread (19 messages)

« previous php.internals (#127236) next »