Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67353 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98721 invoked from network); 7 May 2013 19:38:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 May 2013 19:38:33 -0000 Authentication-Results: pb1.pair.com smtp.mail=krebs.seb@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=krebs.seb@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.177 as permitted sender) X-PHP-List-Original-Sender: krebs.seb@gmail.com X-Host-Fingerprint: 209.85.212.177 mail-wi0-f177.google.com Received: from [209.85.212.177] ([209.85.212.177:49584] helo=mail-wi0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2B/45-06696-83859815 for ; Tue, 07 May 2013 15:38:32 -0400 Received: by mail-wi0-f177.google.com with SMTP id hq12so1070093wib.4 for ; Tue, 07 May 2013 12:38:29 -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=CcnlY8h43nBBKBFD+khUCSmR3vlxvRI8h6V2tpmrdmk=; b=U7T0lAyfk6/FG8VpGVJ/Qp55s3r2GDIsFyRUADdIX1e4tt/5FfiyIOcAtMA9jatUxk 0WuQFtEHKiw58t74dqdJvNOeyLhZFfsgH5n1etsDg20vy5wuuiKBfFzgqKnu2IEhkaRj ON/mbRmq/wsCq9vY0NhCimuzWlV1/2ynb/pN+cGdXoXaFRNcT7/lbvsNRUPYK2NT0KIV qVOiMREGmgZxRBwefbnAFeZT2b7UtNaxv5A2OyYpohLR0c98vKHhw1IO/4Qq8IHxLWuQ 74+G6APyvQ9xeNFxG8RPsWNiI3TLbduirEnTI5RAjKSMh4SNo4EdHpBXFBIwa0BJR2lW B3/w== X-Received: by 10.194.158.37 with SMTP id wr5mr5731398wjb.23.1367955509409; Tue, 07 May 2013 12:38:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.217.79.142 with HTTP; Tue, 7 May 2013 12:38:09 -0700 (PDT) In-Reply-To: References: Date: Tue, 7 May 2013 21:38:09 +0200 Message-ID: To: Thomas Anderson Cc: PHP internals Content-Type: multipart/alternative; boundary=089e013c650a34ff3104dc25f6b1 Subject: Re: [PHP-DEV] idea: letting the line number and file name be set via user_error From: krebs.seb@gmail.com (Sebastian Krebs) --089e013c650a34ff3104dc25f6b1 Content-Type: text/plain; charset=ISO-8859-1 2013/5/7 Thomas Anderson > > > On Tue, May 7, 2013 at 2:04 PM, Sebastian Krebs wrote: > >> >> >> >> 2013/5/7 Thomas Anderson >> >>> 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). >>> >> >> Something I don't understand: You call test() in line 7 and line triggers >> the error, so in fact it is _really_ line 3, that causes the message. So >> why should it display "line 7", when it is obvious the wrong line? >> >> > I thought half the point of OOP was to abstract away the internals and as > is the error messages don't make much sense unless you *do* consider the > internals. > Part of OOP are Exceptions. > > Like let's say you have a bignum library and you're doing > $fifteen->divide($zero) on line 5 of test.php. Seems to me that it'd be > more useful to say "error: division by zero" on line 5 of test.php instead > of line line xx of file yy. It's like... > Somebody else already mentioned, that he wants to trigger notices at first, but here the application is broken. So (see above) Exception is more apropriate. > > "ooh - let me try to find where I'm doing division by zero. Let me to line > xx of file yy that I didn't even write and don't know a thing about. ok... > so it looks like that's in the private _helper_function(). And > _helper_function() is called by 15x other public functions. I give up!" > You should have validated the input parameters before every of the 15 calls. > > As an end user of a library you shouldn't have to actually look into that > library if you're the one who's not properly handling something. > In an ideal world you are propably right, but this is rarely possible/useful. -- github.com/KingCrunch --089e013c650a34ff3104dc25f6b1--