Re: [RFC] Throwable Hierarchy Policy for Extensions

From: Date: Wed, 30 Apr 2025 13:33:44 +0000
Subject: Re: [RFC] Throwable Hierarchy Policy for Extensions
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-127253@lists.php.net to get a copy of this message
On Wed, Apr 30, 2025, at 6:18 AM, Derick Rethans wrote: > On Sun, 27 Apr 2025, Tim Düsterhus wrote: > - Any two exceptions with different causes MUST be identifiable either > by a unique exception class name, a stable `$code`, or a > class-specific additional property suitable for programmatic > consumption (e.g. an enum). > > I would probably not even allow the stable `$code` in here, as > I have > seen from experience people don't really check for them. The only time I've seen anyone use $code is in TYPO3. Their coding standards say that any time you throw an exception, you use the current timestamp (determined manually) as a code. That way there is a globally unique code regardless of exception type that can be grepped to find the exact line it came from. I am not saying this is a good strategy, just that it's the only time I've seen $code used in the wild... --Larry Garfield

« previous php.internals (#127253) next »