Skip to content

Commit 6b5a07c

Browse files
committed
fix(formatters): use flatMap to handle array return from formatInitialException
1 parent 8bd3607 commit 6b5a07c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Issues/Formatters/StackTraceFormatter.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,29 @@ public function format(string $stackTrace, bool $collapseVendorFrames = true): s
1818
{
1919
return collect(explode("\n", $stackTrace))
2020
->filter(fn ($line) => ! empty(trim($line)))
21-
->map(function ($line) use ($collapseVendorFrames) {
21+
->flatMap(function ($line) use ($collapseVendorFrames) {
22+
/** @var string $line */
2223
if (trim($line) === '"}') {
23-
return '';
24+
return [''];
2425
}
2526

2627
if (str_contains($line, '{"exception":"[object] ')) {
2728
return $this->formatInitialException($line);
2829
}
2930

3031
if (! Str::isMatch('/#[0-9]+ /', $line)) {
31-
return $line;
32+
return [$line];
3233
}
3334

3435
$line = str_replace(base_path(), '', $line);
3536

3637
$line = $this->padStackTraceLine($line);
3738

3839
if ($collapseVendorFrames && $this->isVendorFrame($line)) {
39-
return self::VENDOR_FRAME_PLACEHOLDER;
40+
return [self::VENDOR_FRAME_PLACEHOLDER];
4041
}
4142

42-
return $line;
43+
return [$line];
4344
})
4445
->pipe(fn ($lines) => $collapseVendorFrames ? $this->collapseVendorFrames($lines) : $lines)
4546
->join("\n");

0 commit comments

Comments
 (0)