From fb4d1c221490cf2d52d9cfaf0a1cc92f6fad7e3d Mon Sep 17 00:00:00 2001 From: Martin Hason Date: Mon, 10 Jan 2011 15:37:35 +0100 Subject: [PATCH] add methods and fix naming of methods in Twig_Error --- lib/Twig/Error.php | 26 ++++++++++++++++++++++++-- lib/Twig/Parser.php | 4 ++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/lib/Twig/Error.php b/lib/Twig/Error.php index ae6143c..e59785e 100644 --- a/lib/Twig/Error.php +++ b/lib/Twig/Error.php @@ -44,7 +44,7 @@ class Twig_Error extends Exception * * @return string The filename */ - public function getFilename() + public function getTemplateFile() { return $this->filename; } @@ -54,13 +54,35 @@ class Twig_Error extends Exception * * @param string $filename The filename */ - public function setFilename($filename) + public function setTemplateFile($filename) { $this->filename = $filename; $this->updateRepr(); } + /** + * Gets the template line where the error occurred. + * + * @return integer The template line + */ + public function getTemplateLine() + { + return $this->lineno; + } + + /** + * Sets the template line where the error occurred. + * + * @param integer $lineno The template line + */ + public function setTemplateLine($lineno) + { + $this->lineno = $lineno; + + $this->updateRepr(); + } + protected function updateRepr() { $this->message = $this->rawMessage; diff --git a/lib/Twig/Parser.php b/lib/Twig/Parser.php index 88d4181..2e64595 100644 --- a/lib/Twig/Parser.php +++ b/lib/Twig/Parser.php @@ -82,8 +82,8 @@ class Twig_Parser implements Twig_ParserInterface $this->checkBodyNodes($body); } } catch (Twig_Error_Syntax $e) { - if (null === $e->getFilename()) { - $e->setFilename($this->stream->getFilename()); + if (null === $e->getTemplateFile()) { + $e->setTemplateFile($this->stream->getFilename()); } throw $e; -- 1.7.2.5