Hi, Dmitry I've been thinking about all these problems. I can't say a definite decision yet, but I think it will be possible to discuss specific solutions if the community approves this proposal in principle.
At the moment, I was thinking about a similar syntaxis.: try { } catch (ErrorA) catch (ErrorB) { // some handling } or with finally: try { } catch (Error) finally { // ... } чт, 31 июл. 2025 г. в 11:33, Dmitry Derepko <xepo...@gmail.com>: > On Thu, Jul 31, 2025 at 7:55 AM Mihail Liahimov <91lia...@gmail.com> > wrote: > >> Introduction >> >> Currently, PHP requires a block body for catch clauses even when the >> caught exception is not used. This results in unnecessary boilerplate code. >> This RFC proposes allowing catch clauses without a body when the exception >> variable is omitted. >> >> Proposal >> >> Allow the following syntax where the curly braces can be omitted when no >> exception variable is specified and no handling is needed: >> > > Hey! > > I even tried recently to code it. Looked really good and I thought about > publishing it and creating the RFC. > > I have use-cases where I need to try to send a request to a server and > forget about an exception if so: > > try { $client->post(...); } > > If it fails I'm ok with it. > For sure, there are many pitfalls when you allow users to ignore any > exceptions and errors, but it's up to users, right? > > About the proposal: > > try { > // code that may throw > } catch (SomeError); > > How can I catch AnotherError? > > try { > // code that may throw > } catch (SomeError) > catch (AnotherError) { ... } > > OR > > try { > // code that may throw > } catch (AnotherError) { ... } > catch (SomeError); > > What about "finally" construction? > > try { > // code that may throw > } catch (SomeError) > finally {} > > Should the error flow into the "finally" construction? > > > -- > Best regards, > Dmitrii Derepko. > @xepozz >