Skip to content

Commit

Permalink
Addressing scenarios where filepath is missing from stack trace #51
Browse files Browse the repository at this point in the history
  • Loading branch information
madalinoprea committed Mar 18, 2016
1 parent 07e75aa commit 12cc820
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions code/Debug/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public function formatMemorySize($size, $precision = 2)
* @param string $stripFilepath
* @return string
*/
public function formatStacktrace(array $trace, $stripFilepath = '', $trimPath='')
public function formatStacktrace(array $trace, $stripFilepath = '', $trimPath = '')
{
$out = '';
foreach ($trace as $index => $row) {
Expand All @@ -276,12 +276,17 @@ public function formatStacktrace(array $trace, $stripFilepath = '', $trimPath=''
continue;
}

if ($trimPath) {
if ($trimPath && isset($row['file'])) {
$row['file'] = str_replace($trimPath, '', $row['file']);
}

// sometimes there is undefined index 'file'
@$out .= "[$index] {$row['file']}:{$row['line']}\n";
if (isset($row['file'])) {
$out .= "[$index] {$row['file']}:{$row['line']}\n";
} else {
// sometimes there is undefined index 'file'
$out .= "[$index] (?) {$row['class']}:{$row['function']}\n";
}

}

return $out;
Expand Down

0 comments on commit 12cc820

Please sign in to comment.