using Inspectron.Epson.Templates.Language;

namespace Inspectron.Epson.Templates.Validation;

public enum TemplateErrorCode
{
    // Syntax errors (RTL001-RTL010)
    RTL001_UnexpectedToken = 1,
    RTL002_UnclosedBlock = 2,
    RTL003_InvalidDirective = 3,
    RTL004_InvalidBinding = 4,
    RTL005_InvalidForeachSyntax = 5,
    RTL006_InvalidCondition = 6,
    RTL007_UnclosedStyleBlock = 7,
    RTL008_InvalidColumnSpec = 8,
    RTL009_InvalidSeparator = 9,
    RTL010_UnexpectedEndOfFile = 10
}

public record TemplateError(
    TemplateErrorCode Code,
    string Message,
    SourcePosition Position)
{
    public string CodeString => Code.ToString().Split('_')[0];

    public override string ToString() => $"{CodeString}: {Message} at {Position}";
}
