Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67349 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92767 invoked from network); 7 May 2013 19:22:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 May 2013 19:22:00 -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.84 as permitted sender) X-PHP-List-Original-Sender: bobwei9@hotmail.com X-Host-Fingerprint: 65.55.111.84 blu0-omc2-s9.blu0.hotmail.com Windows 2000 SP4, XP SP1 Received: from [65.55.111.84] ([65.55.111.84:8880] helo=blu0-omc2-s9.blu0.hotmail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CB/F3-06696-65459815 for ; Tue, 07 May 2013 15:21:58 -0400 Received: from BLU0-SMTP466 ([65.55.111.73]) by blu0-omc2-s9.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 7 May 2013 12:21:56 -0700 X-EIP: [PSQY7fgvFjyuCTJfeOtFIxoGmqbyhm2/] X-Originating-Email: [bobwei9@hotmail.com] Message-ID: Received: from [192.168.178.93] ([87.240.218.8]) by BLU0-SMTP466.phx.gbl over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 7 May 2013 12:21:53 -0700 Content-Type: multipart/alternative; boundary="Apple-Mail=_D5A1D97B-99C2-4093-A110-6F06D3DAE503" MIME-Version: 1.0 (Mac OS X Mail 6.2 \(1499\)) In-Reply-To: Date: Tue, 7 May 2013 21:21:51 +0200 CC: PHP List Developers Mailing References: To: Sebastian Krebs X-Mailer: Apple Mail (2.1499) X-OriginalArrivalTime: 07 May 2013 19:21:54.0103 (UTC) FILETIME=[22106C70:01CE4B58] Subject: Re: [PHP-DEV] idea: letting the line number and file name be set via user_error From: bobwei9@hotmail.com (Bob Weinand) --Apple-Mail=_D5A1D97B-99C2-4093-A110-6F06D3DAE503 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" Am 7.5.2013 um 21:07 schrieb Sebastian Krebs : >=20 >=20 >=20 > 2013/5/7 Bob Weinand >=20 > Am 7.5.2013 um 18:25 schrieb Ferenc Kovacs : >=20 > > On Tue, May 7, 2013 at 6:09 PM, Thomas Anderson = wrote: > > > >> 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. > >> > >> >> function test() { > >> user_error('whatever'); > >> } > >> > >> test(); > >> ?> > >> > >> 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). > >> > >> 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. > >> > > > > 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.. > > > > I didn't like this proposal. > > > > -- > > Ferenc Kov=E1cs > > @Tyr43l - http://tyrael.hu >=20 > 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. >=20 > Still don't get it: >=20 > if ($errorCond) { > trigger_error(); > } >=20 > The error orginates from at most one line before... And $errorCond may have some long complicated preprocessing by internal = functions of the framework I don't want to know about, so that I cannot = imagine instantly what's going on? > You debug today trigger_error's in libraries with putting a = debug_print_backtrace behind the trigger_error. >=20 > I use a debugger :X I don't know why, but I find it more comfortable to debug with gdb than = with xDebug. With gdb it's only setting a break into the trigger_error = function and then use zbacktrace... But for debugging on some production = system because only there something goes wrong for some reason, I = wouldn't want to install xDebug (which will be loaded at every = request...). =20 > 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...) >=20 > 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. >=20 > 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...) >=20 >=20 > Bob > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20 >=20 >=20 >=20 > --=20 > github.com/KingCrunch=20 Bob --Apple-Mail=_D5A1D97B-99C2-4093-A110-6F06D3DAE503--