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