Re: [PHP-DEV] [RFC] Throwable Hierarchy Policy for Extensions

2025-04-30 Thread Kamil Tekiela
On Wed, 30 Apr 2025 at 21:13, Larry Garfield wrote: > >> […] just that it's the only time I've seen $code used in the wild... > >> > > > > PDO (for better or worse) also uses the `$code` for the error code > > returned by the database. Unfortunately it also widens the (untyped) > > $code from int

Re: [PHP-DEV] [RFC] Throwable Hierarchy Policy for Extensions

2025-04-30 Thread Larry Garfield
On Wed, Apr 30, 2025, at 1:06 PM, Tim Düsterhus wrote: > Hi > > On 4/30/25 15:33, Larry Garfield wrote: >> 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.

Re: [PHP-DEV] [RFC] Throwable Hierarchy Policy for Extensions

2025-04-30 Thread Tim Düsterhus
Hi On 4/30/25 13:18, Derick Rethans wrote: - Exceptions MUST NOT be ``final``. Could the RFC explain why not? I'm not sure if this is useful to add to the RFC itself as a “only extra explanation” and since the discussion is an equally official resource: The reason is to allow flexible exte

Re: [PHP-DEV] [RFC] Throwable Hierarchy Policy for Extensions

2025-04-30 Thread Tim Düsterhus
Hi On 4/30/25 15:33, Larry Garfield wrote: 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 t

Re: [PHP-DEV] [RFC] Throwable Hierarchy Policy for Extensions

2025-04-30 Thread Larry Garfield
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 programm

Re: [PHP-DEV] [RFC] Throwable Hierarchy Policy for Extensions

2025-04-30 Thread Derick Rethans
On Sun, 27 Apr 2025, Tim Düsterhus wrote: > Hi > > as announced in the URI RFC discussion thread > (https://externals.io/message/123997#127142), I've now written up an > “Exception Hierarchy” policy RFC together with Gina. > > Please find the following links: > > RFC: https://wiki.php.net/rfc/e

Re: [PHP-DEV] [RFC] Throwable Hierarchy Policy for Extensions

2025-04-28 Thread Tim Düsterhus
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

Re: [PHP-DEV] [RFC] Throwable Hierarchy Policy for Extensions

2025-04-28 Thread Larry Garfield
On Mon, Apr 28, 2025, at 4:27 PM, Tim Düsterhus wrote: > Hi > > On 4/28/25 23:09, Larry Garfield wrote: * Would allowing an extension-tagging interface instead of a base class be an option? It still allows for catching "anything thrown by this extension", which I presume is the go

Re: [PHP-DEV] [RFC] Throwable Hierarchy Policy for Extensions

2025-04-28 Thread Tim Düsterhus
Hi On 4/28/25 23:09, Larry Garfield wrote: * Would allowing an extension-tagging interface instead of a base class be an option? It still allows for catching "anything thrown by this extension", which I presume is the goal. If not, why? See the “Choice of Base Exception” section in https:/

Re: [PHP-DEV] [RFC] Throwable Hierarchy Policy for Extensions

2025-04-28 Thread Larry Garfield
On Mon, Apr 28, 2025, at 3:30 PM, Tim Düsterhus wrote: > Hi > > On 4/28/25 22:04, Larry Garfield wrote: >> Holy cow, thank you for this bit. The inability to tell what went wrong >> programmatically without string parsing the exception message is one of my >> biggest pet peeves in current except

Re: [PHP-DEV] [RFC] Throwable Hierarchy Policy for Extensions

2025-04-28 Thread Tim Düsterhus
Hi On 4/28/25 22:04, Larry Garfield wrote: Holy cow, thank you for this bit. The inability to tell what went wrong programmatically without string parsing the exception message is one of my biggest pet peeves in current exceptions. Anything particular from the standard library? It might be

Re: [PHP-DEV] [RFC] Throwable Hierarchy Policy for Extensions

2025-04-28 Thread Larry Garfield
On Sun, Apr 27, 2025, at 4:45 PM, Tim Düsterhus wrote: > 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 c

Re: [PHP-DEV] [RFC] Throwable Hierarchy Policy for Extensions

2025-04-27 Thread Tim Düsterhus
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: h

Re: [PHP-DEV] [RFC] Throwable Hierarchy Policy for Extensions

2025-04-27 Thread Kamil Tekiela
>Do you have a wording suggestion to make it clearer what is meant by that sentence? How about this: 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.

Re: [PHP-DEV] [RFC] Throwable Hierarchy Policy for Extensions

2025-04-27 Thread Rob Landers
On Sun, Apr 27, 2025, at 22:40, Kamil Tekiela wrote: > >The exception message MUST NOT be the only property that allows to > differentiate different types of error that the user may be interested in. > > What does this mean exactly? Can you give an example? > Many people don’t know about the $

Re: [PHP-DEV] [RFC] Throwable Hierarchy Policy for Extensions

2025-04-27 Thread Tim Düsterhus
Hi On 4/27/25 22:40, Kamil Tekiela wrote: The exception message MUST NOT be the only property that allows to differentiate different types of error that the user may be interested in. What does this mean exactly? Can you give an example? This is intended to say “if a user calls ->getMessage(

Re: [PHP-DEV] [RFC] Throwable Hierarchy Policy for Extensions

2025-04-27 Thread Kamil Tekiela
>The exception message MUST NOT be the only property that allows to differentiate different types of error that the user may be interested in. What does this mean exactly? Can you give an example?

[PHP-DEV] [RFC] Throwable Hierarchy Policy for Extensions

2025-04-27 Thread Tim Düsterhus
Hi as announced in the URI RFC discussion thread (https://externals.io/message/123997#127142), I've now written up an “Exception Hierarchy” policy RFC together with Gina. Please find the following links: RFC: https://wiki.php.net/rfc/extension_exceptions Policy PR: https://github.com/php/pol