tlang-runtime-compiler/TLang.Parser/CompilerError.cs

39 lines
947 B
C#
Raw Normal View History

2023-07-27 03:31:32 +00:00
using System;
using System.Runtime.Serialization;
namespace TLang.Parser
{
[Serializable]
public class CompilerError : Exception
{
private string ErrorMessage {get;set;}
private Node CurrentNode {get;set;}
public CompilerError()
{
}
public CompilerError(string message) : base(message)
{
}
public CompilerError(string v, Node node) : base(GenerateMessage(v,node))
{
this.ErrorMessage = v;
this.CurrentNode = node;
}
private static string GenerateMessage(string v, Node node)
{
return $"Compiler Error {node.LineInfo}: {v}";
}
public CompilerError(string message, Exception innerException) : base(message, innerException)
{
}
protected CompilerError(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}