Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67339 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74437 invoked from network); 7 May 2013 17:14:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 May 2013 17:14:44 -0000 Authentication-Results: pb1.pair.com header.from=bobwei9@hotmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=bobwei9@hotmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain hotmail.com designates 65.55.111.101 as permitted sender) X-PHP-List-Original-Sender: bobwei9@hotmail.com X-Host-Fingerprint: 65.55.111.101 blu0-omc2-s26.blu0.hotmail.com Windows 2000 SP4, XP SP1 Received: from [65.55.111.101] ([65.55.111.101:49585] helo=blu0-omc2-s26.blu0.hotmail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 49/60-06696-38639815 for ; Tue, 07 May 2013 13:14:43 -0400 Received: from BLU0-SMTP164 ([65.55.111.73]) by blu0-omc2-s26.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 7 May 2013 10:14:40 -0700 X-EIP: [aId16zll3igCjp4EjJl77Lk2uFxu8FEi] X-Originating-Email: [bobwei9@hotmail.com] Message-ID: Received: from [192.168.178.93] ([87.240.218.8]) by BLU0-SMTP164.phx.gbl over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 7 May 2013 10:14:37 -0700 Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 (Mac OS X Mail 6.2 \(1499\)) In-Reply-To: Date: Tue, 7 May 2013 19:14:35 +0200 CC: zelnaga@gmail.com, PHP Mailing List Developers Content-Transfer-Encoding: quoted-printable References: To: Ferenc Kovacs X-Mailer: Apple Mail (2.1499) X-OriginalArrivalTime: 07 May 2013 17:14:37.0967 (UTC) FILETIME=[5A9289F0:01CE4B46] Subject: Re: [PHP-DEV] idea: letting the line number and file name be set via user_error From: bobwei9@hotmail.com (Bob Weinand) Am 7.5.2013 um 18:25 schrieb Ferenc Kovacs : > On Tue, May 7, 2013 at 6:09 PM, Thomas Anderson = wrote: >=20 >> If you do user_error('whatever') it'll show, as the line number for = that >> error, the line number on which that user_error() call is made. It'd = be >> nice if you could control the line number and file name that was = displayed. >> eg. >>=20 >> > function test() { >> user_error('whatever'); >> } >>=20 >> test(); >> ?> >>=20 >> That'll say "Notice: whatever in ... on line 4" (ie. the line that = the >> user_error is on) instead of "Notice: whatever in ... on line 7" (ie. = the >> line that the call to the test() function is made). >>=20 >> If the displayed line numbers could be controlled by user_error then >> debug_backtrace could be used to get the desired line number / file = name to >> display. >>=20 >=20 > line 3, but I suppose that is just a typo on your part. > the default error handler reports the line when the actual error is > generated and it also provides a backtrace so you can see the = callchain for > the execution. > I think that this is a sensible default, and allowing to fake that = from the > userland would make the debugging of the problems harder, as many/most > people would look up the file:line number and would be surprised that = there > is no E_USER_* thrown there. > Additionally I'm not sure how/where would you get your fake line = numbers. > You would either need to hardcode those in your application and make = sure > that the reference and the actual content of your file is in sync (you = will > screw yourself over sooner or later) or you would use __LINE__ + = offset > which is still error prone.. >=20 > I didn't like this proposal. >=20 > --=20 > Ferenc Kov=E1cs > @Tyr43l - http://tyrael.hu And today we have the problem that we cannot use in any useful manner = trigger_error in libraries, when we don't know where the error = originates from. You debug today trigger_error's in libraries with = putting a debug_print_backtrace behind the trigger_error. I think you should be able to track down the error source without = manipulating any library code in the best case (yeah, there exist = Exceptions (there you can add a backtrace) too, but you have to catch = them, if not your script will abort; but I only need a notice...) What I'm doing now is using my own error handler, add a "called at = [line:file]" and output the string myself (via fwrite to STDERR). I = don't think that this is the right way, this seems to me more like a = temporary solution. Please change there something that makes it easier to debug = trigger_error's notices. (But I don't know if only adding a third = parameter to trigger_error is enough...) Bob=