using CanonSharp.Combinator.Abstractions; namespace CanonSharp.Combinator.Results; /// /// 异常类型的失败解析结果 /// /// 解析中发生的异常 /// 当前输入流的状态 /// 输入流类型 /// 当前输入流状态的类型 /// 解析结果的类型 internal sealed class FailedResultWithException(Exception exception, TState state) : IFailedResult where TState : IReadState { public IReadState State => state; public ParseException Exception => new(Message, exception); public string Message => $"Exception occured: {exception}."; public IFailedResult Convert() => new FailedResultWithException(exception, state); public override string ToString() => $"Parse failed: {Message}."; }