add methods and fix naming of methods in Twig_Error

This commit is contained in:
Martin Hason
2011-01-10 15:37:35 +01:00
committed by Fabien Potencier
parent c20116ee8d
commit fb4d1c2214
2 changed files with 26 additions and 4 deletions
+24 -2
View File
@@ -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;
+2 -2
View File
@@ -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;