mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 11:27:00 +00:00
added filename when throwing an exception when we know it
This commit is contained in:
+4
-4
@@ -121,7 +121,7 @@ class Twig_Parser implements Twig_ParserInterface
|
||||
$token = $this->getCurrentToken();
|
||||
|
||||
if ($token->getType() !== Twig_Token::NAME_TYPE) {
|
||||
throw new Twig_Error_Syntax('A block must start with a tag name', $token->getLine());
|
||||
throw new Twig_Error_Syntax('A block must start with a tag name', $token->getLine(), $this->stream->getFilename());
|
||||
}
|
||||
|
||||
if (null !== $test && call_user_func($test, $token)) {
|
||||
@@ -138,7 +138,7 @@ class Twig_Parser implements Twig_ParserInterface
|
||||
|
||||
$subparser = $this->handlers->getTokenParser($token->getValue());
|
||||
if (null === $subparser) {
|
||||
throw new Twig_Error_Syntax(sprintf('Unknown tag name "%s"', $token->getValue()), $token->getLine());
|
||||
throw new Twig_Error_Syntax(sprintf('Unknown tag name "%s"', $token->getValue()), $token->getLine(), $this->stream->getFilename());
|
||||
}
|
||||
|
||||
$this->stream->next();
|
||||
@@ -150,7 +150,7 @@ class Twig_Parser implements Twig_ParserInterface
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Twig_Error_Syntax('Lexer or parser ended up in unsupported state.');
|
||||
throw new Twig_Error_Syntax('Lexer or parser ended up in unsupported state.', -1, $this->stream->getFilename());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ class Twig_Parser implements Twig_ParserInterface
|
||||
||
|
||||
(!$node instanceof Twig_Node_Text && !$node instanceof Twig_Node_BlockReference && $node instanceof Twig_NodeOutputInterface)
|
||||
) {
|
||||
throw new Twig_Error_Syntax(sprintf('A template that extends another one cannot have a body (%s).', $node), $node->getLine());
|
||||
throw new Twig_Error_Syntax(sprintf('A template that extends another one cannot have a body (%s).', $node), $node->getLine(), $this->stream->getFilename());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ class Twig_TokenStream
|
||||
public function next()
|
||||
{
|
||||
if (!isset($this->tokens[++$this->current])) {
|
||||
throw new Twig_Error_Syntax('Unexpected end of template');
|
||||
throw new Twig_Error_Syntax('Unexpected end of template', -1, $this->filename);
|
||||
}
|
||||
|
||||
return $this->tokens[$this->current - 1];
|
||||
@@ -73,7 +73,8 @@ class Twig_TokenStream
|
||||
$message ? $message.'. ' : '',
|
||||
Twig_Token::typeToEnglish($token->getType(), $line), $token->getValue(),
|
||||
Twig_Token::typeToEnglish($type, $line), $value ? sprintf(' with value "%s"', $value) : ''),
|
||||
$line
|
||||
$line,
|
||||
$this->filename
|
||||
);
|
||||
}
|
||||
$this->next();
|
||||
@@ -91,7 +92,7 @@ class Twig_TokenStream
|
||||
public function look($number = 1)
|
||||
{
|
||||
if (!isset($this->tokens[$this->current + $number])) {
|
||||
throw new Twig_Error_Syntax('Unexpected end of template');
|
||||
throw new Twig_Error_Syntax('Unexpected end of template', -1, $this->filename);
|
||||
}
|
||||
|
||||
return $this->tokens[$this->current + $number];
|
||||
|
||||
Reference in New Issue
Block a user