Re: Bug #64910: Line number of $e = new Exception vs. line number of throw $e
| From: | Etienne Kneuss | Date: | Fri, 24 May 2013 15:43:50 +0000 |
| Subject: | Re: Bug #64910: Line number of $e = new Exception vs. line number of throw $e | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-67497@lists.php.net to get a copy of this message | ||
On Fri, May 24, 2013 at 10:44 AM, Stas Malyshev <smalyshev@sugarcrm.com>wrote:
> Hi!
>
> > As a PHP programmer, I would always expect the file/line to refer to
> > the throw statement that has thrown it last. If I wanted to keep track
>
> It is rather surprising that you would expect that as a PHP programmer,
> since it never worked this way in PHP, and no PHP code works this way
> either.
>
> Also, throwing new exception with previous is not the same as throwing
> the same exception twice.
I agree, I think it makes sense to see exceptions as immutable and let
"new" define the line.
If you want to rethrow an exception in a different context while keeping
track of both, I think chaining them is the better approach: throw new
AnotherException("..", 0, $thepreviousexception);
> --
> Stanislav Malyshev, Software Architect
> SugarCRM: http://www.sugarcrm.com/
> (408)454-6900 ext. 227
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Etienne Kneuss
http://www.colder.ch