From 9d88081c94fa0138ed9c16931e3e2412bf6535d0 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 22 Apr 2011 16:06:50 +0200 Subject: [PATCH] tweaked Twig_Error to keep the passed line or template when passed in the constructor and findTemplateInfo() was not able to guess it better --- lib/Twig/Error.php | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Twig/Error.php b/lib/Twig/Error.php index 4064652..61dda79 100644 --- a/lib/Twig/Error.php +++ b/lib/Twig/Error.php @@ -33,7 +33,7 @@ class Twig_Error extends Exception public function __construct($message, $lineno = -1, $filename = null, Exception $previous = null) { if (-1 === $lineno || null === $filename) { - list($lineno, $filename) = $this->findTemplateInfo(null !== $previous ? $previous : $this); + list($lineno, $filename) = $this->findTemplateInfo(null !== $previous ? $previous : $this, $lineno, $filename); } $this->lineno = $lineno; @@ -134,10 +134,10 @@ class Twig_Error extends Exception } } - protected function findTemplateInfo(Exception $e) + protected function findTemplateInfo(Exception $e, $currentLine, $currentFile) { if (!function_exists('token_get_all')) { - return array(-1, null); + return array($currentLine, $currentFile); } $traces = $e->getTrace(); @@ -153,7 +153,7 @@ class Twig_Error extends Exception if (!file_exists($r->getFilename())) { // probably an eval()'d code - return array(-1, null); + return array($currentLine, $currentFile); } $trace = $traces[$i - 1]; @@ -176,9 +176,9 @@ class Twig_Error extends Exception } } - return array(-1, $template); + return array($currentLine, $template); } - return array(-1, null); + return array($currentLine, $currentFile); } } -- 1.7.2.5