IFPSTools.NET/LibIFPSCC/ILineInfo.cs
zc e16c00799d ifpscc: initial commit
libifpscc: initial commit
readme: document ifpscc/libifpscc
license: add credits for ifpscc/libifpscc (derived from code also MIT licensed)
libifps: make additional fields/types public for libifpscc
libifps: fix field documentation for some opcodes
libifps: fix loading functions that are not exported
libifps: allow saving a nonexistant primitive type if the same primitive type was added already
libifps: fix parsing Extended constants
libifps: fix ushort/short being mapped to the wrong types in one table
csproj: set Prefer32Bit=false for release builds
2023-03-28 17:24:19 +01:00

57 lines
1.5 KiB
C#

using System;
using System.Collections;
using System.Dynamic;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
public interface ILineInfo
{
int Line { get; }
int Column { get; }
}
public interface IStoredLineInfo : ILineInfo
{
void Copy(ILineInfo lineInfo);
}
public class ExceptionWithLineInfo : Exception
{
private readonly Exception exception;
private readonly ILineInfo lineInfo;
public override string Message => string.Format("{0} [line {1}, column {2}]", exception.Message, lineInfo.Line, lineInfo.Column);
public override IDictionary Data => exception.Data;
public override Exception GetBaseException()
{
return exception;
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
exception.GetObjectData(info, context);
}
public override string HelpLink { get => exception.HelpLink; set => exception.HelpLink = value; }
public override string Source { get => exception.Source; set => exception.Source = value; }
public override string StackTrace => exception.StackTrace;
public Exception BaseException => exception;
public ExceptionWithLineInfo(Exception exception, ILineInfo lineInfo)
{
this.exception = exception;
this.lineInfo = lineInfo;
}
}
public static class ExceptionWithLineInfoExtensions
{
public static ExceptionWithLineInfo Attach(this Exception exception, ILineInfo lineInfo)
{
return new ExceptionWithLineInfo(exception, lineInfo);
}
}