note 110706 deleted from exception.gettrace by danbrown
| From: | danbrown@php.net | Date: | Thu, 06 Dec 2012 14:13:27 +0000 |
| Subject: | note 110706 deleted from exception.gettrace by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-192304@lists.php.net to get a copy of this message | ||
Note Submitter: Dawid Krysiak
----
This method returns array that is very similar to that returned by debug_backtrace(). One difference
is the one mentioned by sam at notmyrealemail dot org on 17-Feb-2012 04:26
"1) The trace does not include the file / line at which the exception is thrown; that entry is
only recorded in the top-level getFile/Line methods."
So if you want to make it more similar to debug_backtrace() you could do something like this:
<?php
$trace = $exception->getTrace();
array_unshift($trace, array('file' => $exception->getFile(), 'line' =>
$exception->getLine()));
?>
The first element of $trace will have file & line of place where the exception was thrown.
ie. you could then pass it to some common loging mechanism, that accepts both exceptions' trace
and debug_backtrace() output as a parameter.