Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67335 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66669 invoked from network); 7 May 2013 16:25:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 May 2013 16:25:52 -0000 Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.175 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.223.175 mail-ie0-f175.google.com Received: from [209.85.223.175] ([209.85.223.175:46473] helo=mail-ie0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 07/82-54258-01B29815 for ; Tue, 07 May 2013 12:25:52 -0400 Received: by mail-ie0-f175.google.com with SMTP id s9so1321177iec.20 for ; Tue, 07 May 2013 09:25:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=Bi1rpuUbXMTcocxXLXL3oJkM8ZhG1KM7pyDLVTKBRbM=; b=JKnSIrlqV34WOIpKZg0QfptATkZAZAf2ToYPWlXGbq6XfrjDjrgQPu3RfS+y8f6s1L dnFZXmvxaa/290HADcgOVonrDWRx/G0rHjmGJJlygEmY3J6CVNSr1diX6yiN4l0BPxGh C4rqaohTJtXq81baWqI0/F+XsnvrNxXjGnaLbZR5L5xzUScjr8kQcTFF4wYYnYtcq2ql Ij2jQN4cvJshThfzBDUoJoAKjfyZ380nTrdgoYCWuIlNTRgd+OVZzRLpRUopa1wtTzS4 Ru+k03CgBtOSQOZDVcHCPZe/osTqNOLbe5cFovieyVuUo2b3rYrdPKJ25RsZySGgGywp j9EA== MIME-Version: 1.0 X-Received: by 10.50.29.107 with SMTP id j11mr1050585igh.105.1367943949159; Tue, 07 May 2013 09:25:49 -0700 (PDT) Received: by 10.50.209.3 with HTTP; Tue, 7 May 2013 09:25:49 -0700 (PDT) In-Reply-To: References: Date: Tue, 7 May 2013 18:25:49 +0200 Message-ID: To: Thomas Anderson Cc: PHP internals Content-Type: multipart/alternative; boundary=047d7bd760c429957a04dc2345a7 Subject: Re: [PHP-DEV] idea: letting the line number and file name be set via user_error From: tyra3l@gmail.com (Ferenc Kovacs) --047d7bd760c429957a04dc2345a7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 displaye= d. > 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. --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --047d7bd760c429957a04dc2345a7--