Re: [RFC] [Discussion] PREG_THROW_ON_ERROR
| From: | Rowan Tommins [IMSoP] | Date: | Thu, 30 Jul 2026 14:22:24 +0000 |
| Subject: | Re: [RFC] [Discussion] PREG_THROW_ON_ERROR | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-132133@lists.php.net to get a copy of this message | ||
On 30 July 2026 01:21:29 BST, "B.J.Scharp"
<php.list.internals@bitwise-operators.com> wrote:
>On 28-07-2026 2:56 AM, Osama Aldemeery wrote:
>> Hi all,
>
>> The exception name is settled from the pre-RFC as
>>
\PregException
>> (thanks Tim) and the flag as PREG_THROW_ON_ERROR.
>
>From the RFC:
>> The flag covers both classes of PCRE failure.
>
>have you considered throwing different Exception types for the two failure types? (e.g.
>PregExecutionException and PregCompilationException)
>
>
>You could have both be child classes of PregException, but in actual fact, the second should
>probably be a child of LogicException, while the former really is a RuntimeException...
Hi,
We actually have an agreed policy for this: <https://github.com/php/policies/blob/main/coding-standards-and-naming.rst#throwables>
According to that, there has to be a single base extension, which extends directly from \Exception.
Having more specific extensions is definitely encouraged, but these must all extend the
extension's base exception (or each other), not any of the SPL classes like RuntimeException.
If it was a new extension the base exception name would be \Pcre\PcreException but there's
flexibility when adding to existing extensions.
Thanks for bringing up this point,
Rowan Tommins
[IMSoP]