Re: [PHP-DEV] [RFC] [Discussion] PREG_THROW_ON_ERROR

"Rowan Tommins [IMSoP]" <[email protected]> Thu, 30 Jul 2026 15:22:24 +0100
Newsgroups gmane.comp.php.devel
Message-ID <[email protected]>
On 30 July 2026 01:21:29 BST, "B=2EJ=2EScharp" <php=2Elist=2Einternals@bitw=
ise-operators=2Ecom> 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`=2E
>
>From the RFC:
>> The flag covers both classes of PCRE failure=2E
>
>have you considered throwing different Exception types for the two failur=
e types? (e=2Eg=2E 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=2E=2E=2E

Hi,

We actually have an agreed policy for this: <https://github=2Ecom/php/poli=
cies/blob/main/coding-standards-and-naming=2Erst#throwables>

According to that, there has to be a single base extension, which extends =
directly from \Exception=2E

Having more specific extensions is definitely encouraged, but these must a=
ll extend the extension's base exception (or each other), not any of the SP=
L classes like RuntimeException=2E

If it was a new extension the base exception name would be \Pcre\PcreExcep=
tion but there's flexibility when adding to existing extensions=2E

Thanks for bringing up this point,

Rowan Tommins
[IMSoP]