Skip to content

Commit 12cc820

Browse files
committed
Addressing scenarios where filepath is missing from stack trace #51
1 parent 07e75aa commit 12cc820

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

code/Debug/Helper/Data.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public function formatMemorySize($size, $precision = 2)
267267
* @param string $stripFilepath
268268
* @return string
269269
*/
270-
public function formatStacktrace(array $trace, $stripFilepath = '', $trimPath='')
270+
public function formatStacktrace(array $trace, $stripFilepath = '', $trimPath = '')
271271
{
272272
$out = '';
273273
foreach ($trace as $index => $row) {
@@ -276,12 +276,17 @@ public function formatStacktrace(array $trace, $stripFilepath = '', $trimPath=''
276276
continue;
277277
}
278278

279-
if ($trimPath) {
279+
if ($trimPath && isset($row['file'])) {
280280
$row['file'] = str_replace($trimPath, '', $row['file']);
281281
}
282282

283-
// sometimes there is undefined index 'file'
284-
@$out .= "[$index] {$row['file']}:{$row['line']}\n";
283+
if (isset($row['file'])) {
284+
$out .= "[$index] {$row['file']}:{$row['line']}\n";
285+
} else {
286+
// sometimes there is undefined index 'file'
287+
$out .= "[$index] (?) {$row['class']}:{$row['function']}\n";
288+
}
289+
285290
}
286291

287292
return $out;

0 commit comments

Comments
 (0)