|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-05-23 16:07 UTC] sebastian@php.net
Description:
------------
The error message that is created for an uncaught exception as well as the stacktrace of an exception list the number of the line on which the exception object was created. I would expect this to be number of the line on which the exception is raised using the throw statement.
Also note that the documentation on this is inconsistent: the Exception::getLine() method is documented with "Gets the line in which the exception occurred" whereas the Exception::$line attribute is documented with "The line where the exception was created".
Test script:
---------------
<?php
$e = new Exception;
throw $e;
Expected result:
----------------
Fatal error: Uncaught exception 'Exception' in /home/sb/test.php:3
Stack trace:
#0 {main}
thrown in /home/sb/test.php on line 3
Actual result:
--------------
Fatal error: Uncaught exception 'Exception' in /home/sb/test.php:2
Stack trace:
#0 {main}
thrown in /home/sb/test.php on line 2
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 14:00:01 2025 UTC |
Consider however this: try { //stuff } catch(Exception $e) { $logger->log("Oops, exception!"); throw $e; } If we update file/line here, we lose original exception information and file/line in the exception becomes useless. Right now, since 99.99% of the code does "throw new", it is always useful. So how would you propose to solve this?