Skip to content

Commit

Permalink
Use the new compiler path finder system in the debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls committed Sep 12, 2017
1 parent 6721d17 commit 490f63b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/Phug/Renderer/Partial/Debug/DebuggerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,18 @@ private function getRendererException($error, $code, $line, $offset, $source, $s
}
$isPugError = $error instanceof LocatedException;
/* @var LocatedException $error */
if ($isPugError) {
$compiler = $this->getCompiler();
if ($path = $compiler->locate($error->getLocation()->getPath())) {
$source = $compiler->getFileContents($path);
}
}

return new RendererException($this->getErrorMessage(
$error,
$isPugError ? $error->getLocation()->getLine() : $line,
$isPugError ? $error->getLocation()->getOffset() : $offset,
$isPugError && ($path = $error->getLocation()->getPath())
? file_get_contents($path)
: $source,
$source,
$isPugError ? $error->getLocation()->getPath() : $sourcePath,
$colorSupport,
$parameters,
Expand Down Expand Up @@ -206,12 +210,14 @@ private function getDebuggedException($error, $code, $source, $path, $parameters
$line = $pugError->getLocation()->getLine();
$offset = $pugError->getLocation()->getOffset();
$sourcePath = $pugError->getLocation()->getPath() ?: $path;
$compiler = $this->getCompiler();
$sourceFile = $compiler->locate($sourcePath);

if ($sourcePath && !file_exists($sourcePath)) {
if ($sourcePath && !$sourceFile) {
return $error;
}

$source = $sourcePath ? file_get_contents($sourcePath) : $this->debugString;
$source = $sourceFile ? $compiler->getFileContents($sourceFile) : $this->debugString;

return $this->getRendererException($error, $code, $line, $offset, $source, $sourcePath, $parameters, $options);
}
Expand Down

0 comments on commit 490f63b

Please sign in to comment.