Re: Multicatch RFC proposal
| From: | Dan Ackroyd | Date: | Mon, 28 Dec 2015 18:47:22 +0000 |
| Subject: | Re: Multicatch RFC proposal | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-89911@lists.php.net to get a copy of this message | ||
On 24 December 2015 at 22:40, Bronisław Białek <after89@gmail.com> wrote:
> Hello everyone!
>
> I've just created an RFC draft for catching multiple exception types
> in one catch statement:
> https://github.com/bronek89/php-multicatch-rfc
>
> I wrote RFC on github to check if there is any positive response from community.
>
> Basically it introduces possibility to write code such as:
>
> try {
> // ...
> } catch (DbException | ResourceNotFoundException $e) {
> throw new HttpException("not found", 404, $e);
> } catch (\Throwable $e) {
> throw new HttpException("fail", 500, $e);
> }
>
> Provided patch is my first experience with PHP source code, so it
> could be not perfectly written (or simply poor ;-) ) .
>
> What do you think about introducing that kind of feature into PHP?
>
Yes, please. The alternative work-arounds are not as good.
Though I also am concerned about it getting in the way of other
proposals, I don't think it would be an issue. The meaning of the
syntax in your example is pretty obvious. So the only way it could be
a problem is if another RFC proposed a different and 'not as obvious'
meaning.
cheers
Dan