Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67352 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 97157 invoked from network); 7 May 2013 19:32:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 May 2013 19:32:45 -0000 Authentication-Results: pb1.pair.com header.from=adam@adamharvey.name; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=adam@adamharvey.name; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain adamharvey.name designates 209.85.223.182 as permitted sender) X-PHP-List-Original-Sender: adam@adamharvey.name X-Host-Fingerprint: 209.85.223.182 mail-ie0-f182.google.com Received: from [209.85.223.182] ([209.85.223.182:65223] helo=mail-ie0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A5/F4-06696-CD659815 for ; Tue, 07 May 2013 15:32:44 -0400 Received: by mail-ie0-f182.google.com with SMTP id a14so1745099iee.27 for ; Tue, 07 May 2013 12:32:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adamharvey.name; s=google; h=x-received:mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=xqDZ3K4nxV529p/j4eZaC6QslcWDmzR/wtID9Qfgylo=; b=QIFF8QYB83AJfFdGnGq9nTvdp1aR7LcOU3YEe0GzFn9uK8Tpg1/Ef7VIyUCMIVp4I3 9RSUDiFxW9ihx0sLfYNphN7T23jXSTIw3qtKRP8LvsFGR9BMFOZj/q6zOFZvXSWmsqZ7 omQzwZQMGBkUMfRtPL1y7cbpSAt+sVi4UgZtY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :x-gm-message-state; bh=xqDZ3K4nxV529p/j4eZaC6QslcWDmzR/wtID9Qfgylo=; b=koCSIeOR1r9ktR53rckmmgEXV6N1oSoh92+I2hlMOeCNqbb1c1jabLyTCUPR37jIU2 VEq4jWFOOxcALDpolPp27RdOzjNhAxYNncFARk0rB0MBC5qw4W/E9+t4ubyCh7pEon3V dgtfZ8yYm34GLGfz9hfHBNqDDUS47eP3ZuoEc/ohc6buifY28rRD6qx6S8Zxr4deyQEq dWhURQMw7LIrpeShEQLSvCTWYTILnrilQ3HYHz3Gke2fPs0cRAXu4tTHdHdqjqPU7Yla H/H5l8XjIxb2PWh0y0GLcdFWLbN9SgJN2fHbM1CwTr2GwrPmZJ/tYPutmnOxZyVGDypU 3NYw== X-Received: by 10.50.39.35 with SMTP id m3mr3195295igk.42.1367955162074; Tue, 07 May 2013 12:32:42 -0700 (PDT) MIME-Version: 1.0 Sender: adam@adamharvey.name Received: by 10.42.146.65 with HTTP; Tue, 7 May 2013 12:32:21 -0700 (PDT) In-Reply-To: References: Date: Tue, 7 May 2013 12:32:21 -0700 X-Google-Sender-Auth: PlB_zKTinYjBEDMNDRm2mrsyiT8 Message-ID: To: Thomas Anderson Cc: PHP internals Content-Type: text/plain; charset=UTF-8 X-Gm-Message-State: ALoCoQkbAqgJ4IQxWhIJBPM0H5+wr22GqfuzyzNTccuMcl8J+V9bZlAc6l1+WsLZPw3CvC2WI7U0 Subject: Re: [PHP-DEV] idea: letting the line number and file name be set via user_error From: aharvey@php.net (Adam Harvey) On 7 May 2013 12:24, Thomas Anderson wrote: > 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. > > 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... > > "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!" Sure, but in practice, that's why most development environments provide backtraces on error or uncaught exception, whether through something like XDebug or via a call to debug_print_backtrace() in the error/exception handler. That gives you both the specific information you want (the last file and line of non-library code that called into the erroneous function(s)) and all the additional context you might need. As Ferenc said, I also don't understand how you'd get the fake file and line numbers for the trigger_error() call without guesswork or going back up through the backtrace anyway, which is something that doesn't belong in non-handler code, IMO. > 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. I agree, but this is already a solved problem in PHP. All the tools needed are there. Adam