Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93425 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58726 invoked from network); 21 May 2016 18:16:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 May 2016 18:16:40 -0000 Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.218.46 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.218.46 mail-oi0-f46.google.com Received: from [209.85.218.46] ([209.85.218.46:36377] helo=mail-oi0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5D/F4-23824-506A0475 for ; Sat, 21 May 2016 14:16:38 -0400 Received: by mail-oi0-f46.google.com with SMTP id x201so224662118oif.3 for ; Sat, 21 May 2016 11:16:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mindplay-dk.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=o3b6L4UG2XIhFw8CBVbW0YAQfmWG5Z4eAWrVZzekyN4=; b=cSm7ZrPGZwWAKTRMRXaaAO43kIYwIR9z0ob2EN+96aqvaeQVtq4anlwQKoiN1VjPy2 hLF8hUvFs9EdtZlIoZPeIAdbO7RUv7Ff/3sj9QlBOUuoOeH4wBPuVF6WO47V5J2Tnn5q 5DQOemFXEOkRJCUBPENYA3ys5A5I4kgo8DhlMJm+/TNWdcRc3bz9XJcV1UjFyhk+iKxF rhBf9IzP/hevuma7KdrUFi7XRdmo47DNEhfi3Bjfsi0gDCRlcZSG0VfGHG+B+i0sEyXd g9aoDsm8Stu7F0PrfUsJfuNYuuReGM6xCKQYLd0ra3ErNNnEjGBIZ/zSoGgrBd1XgvY5 HUUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=o3b6L4UG2XIhFw8CBVbW0YAQfmWG5Z4eAWrVZzekyN4=; b=lq0+DwRyFH9AnpHXA52rqfh9Q1072pXMSYWhPq1jevU3sOvUgCoHFE7EjFbQsBQd9e H3Zwq4leH9M8p/N0ztoS/bRDbXg7n4p1BVQQWwGu5W+0FwxNssEEPkLZc7A+OAF17gy9 LsOrCsW69gBhDrQbbtYzfTdCcszzpqpRAoyF3Md+dg3HxLmLz4EOY/GyK44wtDQkqEN+ ooGLGSXua5V3MqWePu6oSjWOJcpyEfLhUOMkkvAyhbJkYJwaEJgGAXN3T3vIATUNMRz9 edOEPR0U4fLAzS20lxglcS04thtV/qIVJkMROau9oxYcJQn+pszBXFyFmXUOj9ALsYU1 v01w== X-Gm-Message-State: AOPr4FXQVAVW4dMkOf+uI1/HjK2Jix13N1UfXdlI1LOjsOeZsYxukvAwC7IOpFuQAghCz1cGkTK23juNbPTO6g== MIME-Version: 1.0 X-Received: by 10.157.13.167 with SMTP id 36mr5611742ots.134.1463854595186; Sat, 21 May 2016 11:16:35 -0700 (PDT) Received: by 10.157.44.214 with HTTP; Sat, 21 May 2016 11:16:35 -0700 (PDT) In-Reply-To: References: <72f547d6-5fcf-3cd2-960d-cb612a429e47@php.net> Date: Sat, 21 May 2016 20:16:35 +0200 Message-ID: To: Rowan Collins Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Exception::getLine() From: rasmus@mindplay.dk (Rasmus Schultz) Alright, so forget my comparison with other languages. My other points remain: Presently, "throw new" is treated as though it was one statement. That's not the case. We have deferred throws and factory methods for exceptions, and we have re-throws, so collecting the stack-trace at construction time doesn't work. The construction site would only be relevant if "throw new" was in deed a single statement. Recording the actual throw site is clearly the goal - the current implementation is betting on "throw" and "new" happening at the same site, which is merely circumstance. Ideally, an Exception should collect another stack trace for each successive throw, which would enable you to trace not only the original site, but the flow through any exception-handlers that might have re-thrown the same Exception. As is, there is no information collected on throw, and thereby no evidence or record of possible re-throws - on top of the fact that you may be collecting and looking at bogus stack-traces from factory methods or exception mappers. On Fri, May 20, 2016 at 11:06 AM, Rowan Collins wrote: > On 20/05/2016 08:22, Niklas Keller wrote: >> >> 2016-05-20 4:13 GMT+02:00 Jesse Schalken : >>> >>> The top frame is the construction (get_error) and the site of the throw >>> (do_throw) doesn't appear in the stack at all. >>> >> >> The comparison with JavaScript isn't a good one, since you can throw >> everything in JS. If they didn't provide the stack trace upon throw, you >> would not have a stack trace at all if you throw a plain string. >> > > > That explanation justifies completely the opposite behaviour to what Jesse > described. > > According to MDN [1] the "stack" property is completley unstandardised, and > some engines may indeed populate it on throw, but there's no hint on that > page that they'll attach it to anything not constructed as an Error. > > So it's not a great comparison for either side (note that it was originally > brought up by Rasmus as an example where it *does* come from the throw site) > because the language doesn't actually guarantee you a stack trace at all. > > [1] > https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack > > Regards, > -- > Rowan Collins > [IMSoP] > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >