Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67347 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89440 invoked from network); 7 May 2013 19:08:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 May 2013 19:08:11 -0000 Authentication-Results: pb1.pair.com header.from=krebs.seb@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=krebs.seb@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.178 as permitted sender) X-PHP-List-Original-Sender: krebs.seb@gmail.com X-Host-Fingerprint: 74.125.82.178 mail-we0-f178.google.com Received: from [74.125.82.178] ([74.125.82.178:32944] helo=mail-we0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 85/43-06696-91159815 for ; Tue, 07 May 2013 15:08:10 -0400 Received: by mail-we0-f178.google.com with SMTP id q57so960829wes.9 for ; Tue, 07 May 2013 12:08:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=wPJI3j5fw3aG8uPY50uCgA5obS7mpF8Bma3+h4pSKbU=; b=AsCCoVqygOnrb9Nkev/uM6fEnmfgvRhQZDPJ3OXgVrnbjSzIGwCSTnIUYTzfTqD0Hn aJiTWZrgfPnO/li2/HNrH4n4LVJaukvuJNTNosYZPxGFlq4ReTBisCcwV9zS90B/pbKw gJb7NC7XBto6yr/WcoQexUyda03GmUlxeAnBWvdYrG1FvchXneixaac/eWGJssvNKFRA /rD1ejJ/Gj6okCqGjFyyxzRQucXxnQPC8JKV8/Zfxj6ZQXSW9ePrDgEuLCsKWWmRx+oH 8LCZkfa71kW33ar590azoUuUPnGareYhcd/WmJt3DKuB4ZKQRhP+AhFSQ53iN65I6+FR Bvmg== X-Received: by 10.180.185.114 with SMTP id fb18mr16747953wic.33.1367953687048; Tue, 07 May 2013 12:08:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.217.79.142 with HTTP; Tue, 7 May 2013 12:07:46 -0700 (PDT) In-Reply-To: References: Date: Tue, 7 May 2013 21:07:46 +0200 Message-ID: To: Bob Weinand Cc: Ferenc Kovacs , Thomas Anderson , PHP Mailing List Developers Content-Type: multipart/alternative; boundary=001a11c343da95fa9304dc25896f Subject: Re: [PHP-DEV] idea: letting the line number and file name be set via user_error From: krebs.seb@gmail.com (Sebastian Krebs) --001a11c343da95fa9304dc25896f Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 2013/5/7 Bob Weinand > > Am 7.5.2013 um 18:25 schrieb Ferenc Kovacs : > > > 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 th= at > >> 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 number= s. > > You would either need to hardcode those in your application and make su= re > > 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 > > 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. Still don't get it: if ($errorCond) { trigger_error(); } The error orginates from at most one line before... > You debug today trigger_error's in libraries with putting a > debug_print_backtrace behind the trigger_error. > I use a debugger :X > 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 the= m, > 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 paramet= er > to trigger_error is enough...) > > > Bob > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --=20 github.com/KingCrunch --001a11c343da95fa9304dc25896f--