Skip to content

Please report betters errors (context) when having mistakes in the template #314

@304NotModified

Description

@304NotModified

Example 1

{{#File}} (mistake, should be {{File}}

gives:

HandlebarsDotNet.HandlebarsCompilerException: Reached end of template before block expression '' was closed
    at HandlebarsDotNet.Compiler.BlockAccumulator.AccumulateBlock(IEnumerator`1 enumerator, BlockAccumulatorContext context)
   at HandlebarsDotNet.Compiler.BlockAccumulator.<ConvertTokens>d__3.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at HandlebarsDotNet.Compiler.BlockAccumulator.Accumulate(IEnumerable`1 tokens, HandlebarsConfiguration configuration)
   at HandlebarsDotNet.Compiler.ExpressionBuilder.ConvertTokensToExpressions(IEnumerable`1 tokens)
   at HandlebarsDotNet.Compiler.HandlebarsCompiler.Compile(TextReader source)
   at HandlebarsDotNet.Handlebars.HandlebarsEnvironment.Compile(String template)
   at HandlebarsDotNet.Handlebars.Compile(String template)

Example 2

{{File}}}

HandlebarsDotNet.HandlebarsCompilerException: Starting and ending handlebars do not match
    at HandlebarsDotNet.Compiler.ExpressionScopeConverter.<ConvertTokens>d__2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at HandlebarsDotNet.Compiler.ExpressionScopeConverter.Convert(IEnumerable`1 sequence)
   at HandlebarsDotNet.Compiler.ExpressionBuilder.ConvertTokensToExpressions(IEnumerable`1 tokens)
   at HandlebarsDotNet.Compiler.HandlebarsCompiler.Compile(TextReader source)
   at HandlebarsDotNet.Handlebars.HandlebarsEnvironment.Compile(String template)
   at HandlebarsDotNet.Handlebars.Compile(String template)

Missing line / column numbers

Example 3

{{#if !File}} {{/if}} (wrong !)

HandlebarsDotNet.HandlebarsCompilerException: An unhandled exception occurred while trying to compile the template ---> HandlebarsDotNet.HandlebarsCompilerException: An unhandled exception occurred while trying to compile the template ---> System.ArgumentException: must be reducible node
    at System.Linq.Expressions.Expression.VisitChildren(ExpressionVisitor visitor)
   at System.Linq.Expressions.ExpressionVisitor.VisitExtension(Expression node)
   at System.Linq.Expressions.Expression.Accept(ExpressionVisitor visitor)
   at HandlebarsDotNet.Compiler.HandlebarsExpressionVisitor.Visit(Expression exp)
   at HandlebarsDotNet.Compiler.HandlebarsExpressionVisitor.VisitBoolishExpression(BoolishExpression bex)
   at HandlebarsDotNet.Compiler.HandlebarsExpressionVisitor.Visit(Expression exp)
   at System.Linq.Expressions.ExpressionVisitor.VisitConditional(ConditionalExpression node)
   at System.Linq.Expressions.ConditionalExpression.Accept(ExpressionVisitor visitor)
   at HandlebarsDotNet.Compiler.HandlebarsExpressionVisitor.Visit(Expression exp)
   at System.Linq.Expressions.ExpressionVisitor.VisitBlock(BlockExpression node)
   at System.Linq.Expressions.BlockExpression.Accept(ExpressionVisitor visitor)
   at HandlebarsDotNet.Compiler.HandlebarsExpressionVisitor.Visit(Expression exp)
   at HandlebarsDotNet.Compiler.FunctionBuilder.Compile(IEnumerable`1 expressions, Expression parentContext, String templatePath)
--- End of inner exception stack trace ---
    at HandlebarsDotNet.Compiler.FunctionBuilder.Compile(IEnumerable`1 expressions, Expression parentContext, String templatePath)
   at HandlebarsDotNet.Compiler.FunctionBuilder.Compile(IEnumerable`1 expressions, String templatePath)
--- End of inner exception stack trace ---
    at HandlebarsDotNet.Compiler.FunctionBuilder.Compile(IEnumerable`1 expressions, String templatePath)
   at HandlebarsDotNet.Compiler.HandlebarsCompiler.Compile(TextReader source)
   at HandlebarsDotNet.Handlebars.HandlebarsEnvironment.Compile(String template)
   at HandlebarsDotNet.Handlebars.Compile(String template)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions