Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86363 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16219 invoked from network); 24 May 2015 14:31:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 May 2015 14:31:37 -0000 Authentication-Results: pb1.pair.com smtp.mail=tpunt@hotmail.co.uk; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tpunt@hotmail.co.uk; sender-id=pass Received-SPF: pass (pb1.pair.com: domain hotmail.co.uk designates 157.55.2.94 as permitted sender) X-PHP-List-Original-Sender: tpunt@hotmail.co.uk X-Host-Fingerprint: 157.55.2.94 dub004-omc4s19.hotmail.com Received: from [157.55.2.94] ([157.55.2.94:57132] helo=DUB004-OMC4S19.hotmail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 55/70-08079-7C0E1655 for ; Sun, 24 May 2015 10:31:36 -0400 Received: from DUB113-W128 ([157.55.2.72]) by DUB004-OMC4S19.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.22751); Sun, 24 May 2015 07:31:33 -0700 X-TMN: [KIzFE710cdekKGz/Ig6rf9kLVrNnxqEh] X-Originating-Email: [tpunt@hotmail.co.uk] Message-ID: To: =?iso-8859-2?B?SmFrdWIgS3Vi7ehlaw==?= , Benjamin Morel CC: PHP Internals Date: Sun, 24 May 2015 15:31:32 +0100 Importance: Normal In-Reply-To: References: <000301d09526$ee7b0580$cb711080$@gmail.com>, Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginalArrivalTime: 24 May 2015 14:31:33.0089 (UTC) FILETIME=[54E7E510:01D0962E] Subject: RE: [PHP-DEV] Allow __toString() to throw exceptions From: tpunt@hotmail.co.uk (Thomas Punt) Hey=2C=0A= =0A= > I have a question: is there any reason to throw an exception from=0A= > __toString=2C *other* than a non-recoverable error=2C which would denote = that=0A= > the object=2C which the __toString method is called on=2C does not have a= ny=0A= > meaningful string representation? Because if not=2C core implementation f= ully=0A= > serves its purpose throwing Fatal error now=2C even if it is non-standard= way.=0A= =0A= The problem with not enabling __toString to throw exceptions is that if any= =0A= exceptions thrown are by the engine itself (for things like uncallable func= tions)=2C=0A= then the method returns an unrelated E_ERROR regarding the inability to=0A= throw exceptions.=0A= =0A= The code example [1] shows this where the old message was:=0A= "Fatal error: Call to undefined function a() in..."=0A= =0A= and now after the inclusion of exceptions in the engine=2C it is:=0A= "Fatal error: Method Test::__toString() must not throw an exception in..."= =0A= =0A= This is obviously not an overly helpful response=2C and the E_ERROR cannot = be=0A= caught either.=0A= =0A= Thanks=2C=0A= Tom=0A= =0A= [1] http://3v4l.org/eGc1d=0A= =0A= =