Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45075 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 97685 invoked from network); 24 Jul 2009 14:07:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Jul 2009 14:07:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=mail@dasprids.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=mail@dasprids.de; sender-id=unknown Received-SPF: error (pb1.pair.com: domain dasprids.de from 213.239.215.81 cause and error) X-PHP-List-Original-Sender: mail@dasprids.de X-Host-Fingerprint: 213.239.215.81 dasprids.de Linux 2.4/2.6 Received: from [213.239.215.81] ([213.239.215.81:38633] helo=dasprids.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 46/1B-39659-800C96A4 for ; Fri, 24 Jul 2009 10:07:06 -0400 Received: from [192.168.0.86] (HSI-KBW-078-042-024-238.hsi3.kabel-badenwuerttemberg.de [78.42.24.238]) by dasprids.de (Postfix) with ESMTPSA id 84044204002; Fri, 24 Jul 2009 16:06:58 +0200 (CEST) Message-ID: <4A69C001.7090208@dasprids.de> Date: Fri, 24 Jul 2009 16:06:57 +0200 Organization: DASPRiD's User-Agent: Thunderbird 2.0.0.22 (X11/20090608) MIME-Version: 1.0 To: Kalle Sommer Nielsen CC: internals@lists.php.net References: <2dedb8a0907240640i118d220fte7ed4e0285aae024@mail.gmail.com> <2dedb8a0907240654n59a4376ax552fb59f9ec4a5f6@mail.gmail.com> In-Reply-To: <2dedb8a0907240654n59a4376ax552fb59f9ec4a5f6@mail.gmail.com> X-Enigmail-Version: 0.95.7 OpenPGP: id=6B3BF3D0; url=http://pgp.dasprids.de/Ben%20Scholzen%20'DASPRiD'%20mail@dasprids.de%20(0x6B3BF3D0)%20pub.asc Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] RFC: Replacing errors with Exceptions From: mail@dasprids.de (Ben Scholzen 'DASPRiD') -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Kalle Sommer Nielsen wrote: > Then ZF should provide an error handler that can be called inside the > user's error handler or simply choose to not use error handlers if the > user have a custom error handler. I can't really see why the whole > language should change into using exceptions by default because of > something like this? This second suggested solution doesn't change the current behaviour at all, just adds an additional one, which under usual circumstances will never appear. Again, say for example, you have the following code: - ------------------------------ $fp = @fopen(...); if (!$fp) { // !some! error occured, handle it } - ------------------------------ I already described the problems with this in the RFC, e.g. you don't know, which error occurded, just that fopen failed. What a library currently would have to do is: - ------------------------------ function exception_error_handler($errno, $errstr, $errfile, $errline ) { throw new ErrorException($errstr, 0, $errno, $errfile, $errline); } set_error_handler('exception_error_handler'); try { $fp = fopen(…); } catch (ErrorException $e) { // Handle the exception } restore_error_handler(); - ------------------------------ One could surely do that, yet it is not only unneccesary much additional code, but also introduces overhead by setting and restoring the error handler again and again. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkppwAEACgkQ0HfT5Ws789DWiACgybJm1vq+Hrmtm0s1zoJ4sS0n TzoAnRtx6fT9CFn+zn8goCWByxIij6np =cmFn -----END PGP SIGNATURE-----