Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Do not display the "from" section for the first exception trace entry
According to http://php.net/manual/en/exception.gettrace.php#107563, the first entry may not contain the file/line keys.

Additionally, some changes to the output formatting have been made:

1. The trace entries are counted in a human-friendly way starting with "1" (like Xdebug does for example).
2. The file name and line number in the "from" section are delimited by a colon without the space. This format is better IDE/editor friendly and helps easier navigation (e.g. Ctrl+N in PhpStorm, copy-paste the file:line combination).

Fixes #108.
  • Loading branch information
morozov committed Nov 30, 2017
commit 9da91f3b2610b5cd27975a3a7c197714cadd452b
21 changes: 18 additions & 3 deletions src/ExceptionPrinter/DevelopmentExceptionPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,23 @@ public function dumpTrace(Exception $e)

$argDesc = $this->dumpArgs($entry['args']);

$this->logger->info(sprintf(" %d) %s%s%s(%s)", $idx, @$entry['class'], @$entry['type'], $entry['function'], $argDesc));
$this->logger->info(sprintf(" from %s: %d", $entry['file'], $entry['line']));
$this->logger->info(sprintf(
" %d) %s%s%s(%s)",
$idx + 1,
@$entry['class'],
@$entry['type'],
$entry['function'],
$argDesc
));

if (isset($entry['file'], $entry['line'])) {
$this->logger->info(sprintf(
" from %s: %d",
$entry['file'],
$entry['line']
));
}

$this->logger->newline();
}
$this->logger->newline();
Expand Down Expand Up @@ -141,7 +156,7 @@ public function dumpBrief(Exception $e)
}
}

public function dump(Exception $e)
public function dump(Exception $e)
{
$this->dumpBrief($e);
$this->dumpCodeBlock($e);
Expand Down