ID: 51067 Updated by: j...@php.net Reported By: Mateusz Przybylski <m dot przybylski at bkfmyjn -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: linux PHP Version: 5.2.12 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Previous Comments: ------------------------------------------------------------------------ [2010-02-17 09:31:33] Mateusz Przybylski <m dot przybylski at bkfmyjn Description: ------------ An exception contains context (backtrace etc.) from the point it was created, not where it was thrown. I realize one could argue for either way, but IMHO it is more useful to have it report point where it was thrown from than the place of instantination. Point in case: a function that translates certain error codes returned from external system into exceptions. It makes no sense to indicate the function itself as source of exceptional condition. The function could be used by several functions interacting with the remote system for common error signaling. Example use: (NOT reproduce code) function queryRemoteSystem($qry) { sendQry($qry); $r = readResponse(); if ($r === false) throw remoteSystemException(); /* dis a function call, yo */ } function remoteSystemException() { switch (remoteErrorCode()) { case FOO: return new FooException(); case BAR: return new BarException(); default: return new GeneralRemoteException(); } } Reproduce code: --------------- function creates($msg) { return new Exception($msg); } function throws() { throw creates('foo bar'); } try { throws(); } catch (Exception $e) { $trace = $e->getTrace(); $firstFrame = $trace[0]; echo 'Exception from function: '.$firstFrame['function']; } Expected result: ---------------- Exception from function: throws Actual result: -------------- Exception from function: creates ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=51067&edit=1