39 lines
947 B
C#
39 lines
947 B
C#
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)
|
|
{
|
|
}
|
|
}
|
|
} |