Re: [RFC] Optional Catch Block Body
| From: | Christian Schneider | Date: | Thu, 31 Jul 2025 13:46:41 +0000 |
| Subject: | Re: [RFC] Optional Catch Block Body | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-128344@lists.php.net to get a copy of this message | ||
Am 31.07.2025 um 13:16 schrieb Rowan Tommins [IMSoP] <imsop.php@rwec.co.uk>:
> I think an inline syntax like this would be a powerful feature, and a potential replacement for
> the @ operator:
>
> $fh = null;
> $fh = try fopen($filePath, 'w') ignore (FileLockedException);
First of all: I'm wary because partial error handling seems dangerous to mel do I know all
possible Exception types and which ones should abort and which ones should continue? Or will it
encourage try ... ignore (Exception)? I have to admit that I'm also a sceptic of converting
every possible info/warning/error to an Exception but that's a different topic ;-)
If we decide to add something like the above I would very much prefer the try ... ignore block to be
an expression with value null on error, making the first line obsolete. One could still use
$lines = try file($filepath) ignore (FileLockedException) ?? [];
if another default value is preferred.
Regards,
- Chris