Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45073 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94010 invoked from network); 24 Jul 2009 13:43:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Jul 2009 13:43:52 -0000 X-Host-Fingerprint: 78.42.24.238 HSI-KBW-078-042-024-238.hsi3.kabel-badenwuerttemberg.de Received: from [78.42.24.238] ([78.42.24.238:3663] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CA/5A-39659-79AB96A4 for ; Fri, 24 Jul 2009 09:43:52 -0400 Message-ID: To: internals@lists.php.net Date: Fri, 24 Jul 2009 15:43:48 +0200 User-Agent: Thunderbird 2.0.0.22 (X11/20090608) MIME-Version: 1.0 References: <2dedb8a0907240640i118d220fte7ed4e0285aae024@mail.gmail.com> In-Reply-To: <2dedb8a0907240640i118d220fte7ed4e0285aae024@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Posted-By: 78.42.24.238 Subject: Re: [PHP-DEV] RFC: Replacing errors with Exceptions From: mail@dasprids.de (Ben Scholzen 'DASPRiD') To you both, this is especially, for library code like Zend Framework. The library cannot expect the user to have the error handle set, so it would have to replace the error handler before every line which it wants to try {} and reset it after the catch. This is not really a clean solution, at it can occur pretty often. Kalle Sommer Nielsen schrieb: > 2009/7/24 : >> I published a (work in progress) RFC today about replacing certain >> errors with exceptions. I know that there already was something similiar >> on the php6dev blog, but this is not completly the same, so awating your >> comments: >> >> http://wiki.php.net/rfc/errors_as_exceptions >> > > I'm a big -1, I don't see a big reason for wrapping all my code in a > try/catch block when im writing flat out procedural for example, PHP > isn't an OO-only language, if you need to catch such errors via > exceptions you can simply do it by having a custom error handler and > the ErrorException as you linked to, like: > > set_error_handler(function($severity, $message, $file = NULL, $line = > NULL, $context = NULL) > { > if(!(error_reporting() & $severity)) > { > return; > } > > throw new ErrorException($message, 0, $severity, $file, $line, > $context); > }); > > I don't know if PHP should adopt code into the core that can be done > in less than 10 lines, however with an ini setting it might work as > long its off by default, but I'm not sure how many others here are > happy about adding another ini setting for this. > > > ps. Fix your email when posting > > -- ................................... : ___ _ ___ ___ ___ _ ___ : : | \ /_\ / __| _ \ _ (_) \ : : | |) / _ \\__ \ _/ / | |) | : : |___/_/:\_\___/_| |_|_\_|___/ : :........:........................: : Web : http://www.dasprids.de : : E-mail : mail@dasprids.de : : Jabber : jabber@dasprids.de : : ICQ : 105677955 : :........:........................: