|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-06-20 15:38 UTC] tomas_matousek at hotmail dot com
Description:
------------
Exception stack trace is created by the new operator and not when the exception is thrown. Is that an intention or a bug? I think it is bug and that it was intended to trace throwing of the exception since the stack trace message contains
"thrown in ..."
and not
"created in ...".
Reproduce code:
---------------
<?
function f()
{
return new Exception("hello");
}
try
{
$a = f();
throw $a;
}
catch(Exception $e)
{
throw $e;
}
Expected result:
----------------
Fatal error: Uncaught exception 'Exception' with message 'hello' in C:\Web\$PhpTests\z.php:14
Stack trace:
#0 C:\Web\$PhpTests\z.php(14):
#1 {main}
thrown in C:\Web\$PhpTests\z.php on line 14
Actual result:
--------------
Fatal error: Uncaught exception 'Exception' with message 'hello' in C:\Web\$PhpTests\z.php:4
Stack trace:
#0 C:\Web\$PhpTests\z.php(4): f()
#1 C:\Web\$PhpTests\z.php(9): f()
#2 {main}
thrown in C:\Web\$PhpTests\z.php on line 4
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 00:00:01 2025 UTC |
Well, that's the point of all of that! I don't want to catch it because I want the stack trace to be shown. Alternatively, I can add try { } catch(Exception $f) { echo $f; } and the effect would be the same - a wrong stack trace would be printed. This has nothing to do with leaving exception uncaught.