diff --git a/lib/Twig/Node/Module.php b/lib/Twig/Node/Module.php index 55cb1a846..4cb6c195a 100644 --- a/lib/Twig/Node/Module.php +++ b/lib/Twig/Node/Module.php @@ -198,7 +198,9 @@ class Twig_Node_Module extends Twig_Node ->indent() ->write("throw new Twig_Error_Runtime('Template \"'.") ->subcompile($trait->getNode('template')) - ->raw(".'\" cannot be used as a trait.');\n") + ->raw(".'\" cannot be used as a trait.', ") + ->repr($node->getTemplateLine()) + ->raw(", \$this->source);\n") ->outdent() ->write("}\n") ->write(sprintf("\$_trait_%s_blocks = \$_trait_%s->getBlocks();\n\n", $i, $i)) @@ -210,11 +212,13 @@ class Twig_Node_Module extends Twig_Node ->string($key) ->raw("])) {\n") ->indent() - ->write("throw new Twig_Error_Runtime(sprintf('Block ") + ->write("throw new Twig_Error_Runtime('Block ") ->string($key) ->raw(' is not defined in trait ') ->subcompile($trait->getNode('template')) - ->raw(".'));\n") + ->raw(".', ") + ->repr($node->getTemplateLine()) + ->raw(", \$this->source);\n") ->outdent() ->write("}\n\n") diff --git a/lib/Twig/Node/With.php b/lib/Twig/Node/With.php index 2ab0ea5d7..baf721d0e 100644 --- a/lib/Twig/Node/With.php +++ b/lib/Twig/Node/With.php @@ -38,7 +38,9 @@ class Twig_Node_With extends Twig_Node ->raw(";\n") ->write(sprintf("if (!is_array(\$%s)) {\n", $varsName)) ->indent() - ->write("throw new Twig_Error_Runtime('Variables passed to the \"with\" tag must be a hash.');\n") + ->write("throw new Twig_Error_Runtime('Variables passed to the \"with\" tag must be a hash.', ") + ->repr($this->getTemplateLine()) + ->raw(", \$this->source);\n") ->outdent() ->write("}\n") ;