Skip to content

Commit

Permalink
Better error display for dev environments (#4363)
Browse files Browse the repository at this point in the history
* Better error display for dev environments

Adding file and line numbers for the error display in dev environments to support and speed up template development.

* Style update ;)

* May the linter be with you
  • Loading branch information
Andreas Schönefeldt authored and danrot committed Jan 23, 2019
1 parent fc11055 commit 34307c5
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ public function render($object, $id, $webspaceKey, $locale, $partial = false, $t
try {
$response = $this->handle($request);
} catch (\Twig_Error $e) {
// dev/test only: display also the file and line which was causing the error
// for better debugging and faster development
if (in_array($this->environment, ['dev', 'test'])) {
$e->appendMessage(' (' . $e->getFile() . ' line ' . $e->getLine() . ')');
}

throw new TwigException($e, $object, $id, $webspace, $locale);
} catch (\InvalidArgumentException $e) {
throw new TemplateNotFoundException($e, $object, $id, $webspace, $locale);
Expand Down

0 comments on commit 34307c5

Please sign in to comment.