Re: [RFC] Exceptions in the engine
| From: | Rowan Collins | Date: | Sun, 15 Feb 2015 22:52:57 +0000 |
| Subject: | Re: [RFC] Exceptions in the engine | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-82762@lists.php.net to get a copy of this message | ||
On 14/02/2015 00:09, Yasuo Ohgaki wrote:
Hi Nikita, On Tue, Oct 7, 2014 at 6:53 AM, Nikita Popov <nikita.ppv@gmail.com> wrote:Much though I'd love a more OO-approach to warnings, exceptions are not an appropriate mechanism for that. A rule of thumb I rather like is that you should only throw an exception in a case where your best alternative, if it is not handled, is to call die(). Clearly, E_ERROR meets this standard, and E_WARNING does not. There has been much talk previously that "exceptions are great because they include full backtraces", but there's no reason a new type of warning object couldn't also include those, while retaining the key characteristic of the default behaviour being to carry on with some fallback value (an empty loop, a null variable, etc) rather than to die('Uncaught Warning Exception!'). Regards, -- Rowan Collins [IMSoP]As such I'm re-proposing this RFC for inclusion in PHP 7:Are E_WARNING, etc future scope? I briefly looked the patch. It seems it covers only engine errors. I suppose it's the scope of this RFC, though. If API is made adoptable to modules for E_WARNING, etc, it would be great.https://wiki.php.net/rfc/engine_exceptions_for_php7The RFC text is essentially the same as previously, with the primary difference being that parse errors are now converted to exceptions as well. This was previously not possible due to limitations in the compiler design.