public Exception Error(string message) { var startPos = AtEnd ? _tokens[_index - 1].EndPos : _tokens[_index].StartPos; var endPos = AtEnd ? _tokens[_index - 1].EndPos : _tokens[_index].EndPos; var programWithLines = new ProgramWithLines(_program); return(new JsonMasherException( message, programWithLines.GetLineNumber(startPos) + 1, programWithLines.GetColumnNumber(startPos) + 1, PositionHighlighter.Highlight(programWithLines, startPos, endPos))); }
internal Exception Error( string message, int? positionNullable = null, int? lengthNullable = null, Exception ex = null) { var position = positionNullable == null ? _index : positionNullable.Value; var length = lengthNullable == null ? 1 : lengthNullable.Value; var programWithLines = new ProgramWithLines(_program); return new JsonMasherException( message, programWithLines.GetLineNumber(position) + 1, programWithLines.GetColumnNumber(position) + 1, PositionHighlighter.Highlight(programWithLines, position, position + length), ex); }