$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)) {
$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();
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());
}
}
||
(!$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());
}
}
}
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];
$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();
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];