Skip to content

Entire data object is included in output on ParseError, when ParseErrorAction is set to anything other than ThrowError #143

@andersjonsson

Description

@andersjonsson

Template: "Hello {Name"

That template is clearly missing an end curly brace

Smart.Format("Hello {Name", new { Name = "Anders Jonsson", City = "Stockholm"})
//Result: Exception

So far so good.

But after setting Smart.Default.Settings.ParseErrorAction I get an unexpected output.

Smart.Default.Settings.ParseErrorAction = SmartFormat.Core.Settings.ErrorAction.Ignore;
Smart.Format("Hello {Name", new { Name = "Anders Jonsson", City = "Stockholm"})
//Result: "Hello { Name = Anders Jonsson, City = Stockholm }Name"

Smart.Default.Settings.ParseErrorAction = SmartFormat.Core.Settings.ErrorAction.MaintainTokens;
Smart.Format("Hello {Name", new { Name = "Anders Jonsson", City = "Stockholm"})
//Result: "Hello { Name = Anders Jonsson, City = Stockholm }Name"

Smart.Default.Settings.ParseErrorAction = SmartFormat.Core.Settings.ErrorAction.OutputErrorInResult;
Smart.Format("Hello {Name", new { Name = "Anders Jonsson", City = "Stockholm"})
//Result: "Hello { Name = Anders Jonsson, City = Stockholm }Name"

That doesn't seem like the intended behavior. Am I missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions