Skip to content

Commit 9e1b41f

Browse files
committed
get stacktrace from stringified exception
1 parent 77e2ee1 commit 9e1b41f

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/PhpStormPrinter.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,16 @@ protected function printDefect(TestFailure $defect, int $count): void
4242
*/
4343
protected function printDefectFooter(TestFailure $defect): void
4444
{
45-
foreach ($defect->thrownException()->getTrace() as $frame) {
46-
if (false === strpos($frame['file'], 'vendor/phpunit/phpunit')) {
47-
$offender = $frame;
45+
$trace = explode(PHP_EOL, trim((string) $defect->thrownException()));
46+
$offender = end($trace);
4847

49-
break;
50-
}
51-
}
48+
[$file, $line] = explode(':', $offender);
5249

53-
if (isset($offender)) {
50+
if (isset($file, $line)) {
5451
$this->write(sprintf(
5552
"✏️ phpstorm://open?file=%s&line=%d\n",
56-
$offender['file'],
57-
$offender['line']
53+
$file,
54+
$line
5855
));
5956
}
6057
}

0 commit comments

Comments
 (0)