Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fusion] Renamed SyntaxException to FieldSelectionMapSyntaxException #7947

Merged
merged 2 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace HotChocolate.Fusion;

[Serializable]
public sealed class FieldSelectionMapSyntaxException : Exception
{
internal FieldSelectionMapSyntaxException(
FieldSelectionMapReader reader,
string message)
: base(message)
{
Position = reader.Position;
Line = reader.Line;
Column = reader.Column;
}

internal FieldSelectionMapSyntaxException(
FieldSelectionMapReader reader,
string message,
params object[] args)
: this(reader, string.Format(message, args))
{
}

public int Position { get; }

public int Line { get; }

public int Column { get; }
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ private SelectedValueEntryNode ParseSelectedValueEntry()
break;

default:
throw new SyntaxException(_reader, UnexpectedToken, _reader.TokenKind);
throw new FieldSelectionMapSyntaxException(
_reader,
UnexpectedToken,
_reader.TokenKind);
}

var location = CreateLocation(in start);
Expand Down Expand Up @@ -335,7 +338,7 @@ private TokenInfo Start()
{
if (++_parsedNodes > _options.MaxAllowedNodes)
{
throw new SyntaxException(
throw new FieldSelectionMapSyntaxException(
_reader,
string.Format(MaxAllowedNodesExceeded, _options.MaxAllowedNodes));
}
Expand All @@ -353,7 +356,11 @@ private void Expect(TokenKind tokenKind)
{
if (!_reader.Skip(tokenKind))
{
throw new SyntaxException(_reader, InvalidToken, tokenKind, _reader.TokenKind);
throw new FieldSelectionMapSyntaxException(
_reader,
InvalidToken,
tokenKind,
_reader.TokenKind);
}
}

Expand All @@ -368,7 +375,11 @@ private string ExpectName()
return name;
}

throw new SyntaxException(_reader, InvalidToken, TokenKind.Name, _reader.TokenKind);
throw new FieldSelectionMapSyntaxException(
_reader,
InvalidToken,
TokenKind.Name,
_reader.TokenKind);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public FieldSelectionMapReader(
/// <returns>
/// Returns a boolean indicating if the read was successful.
/// </returns>
/// <exception cref="SyntaxException">
/// <exception cref="FieldSelectionMapSyntaxException">
/// The source text contains an invalid syntax token.
/// </exception>
public bool Read()
Expand All @@ -100,7 +100,7 @@ public bool Read()

if (_tokenCount > _maxAllowedTokens)
{
throw new SyntaxException(
throw new FieldSelectionMapSyntaxException(
this,
string.Format(MaxAllowedTokensExceeded, _maxAllowedTokens));
}
Expand All @@ -121,7 +121,7 @@ public bool Read()
return true;
}

throw new SyntaxException(this, UnexpectedCharacter, code);
throw new FieldSelectionMapSyntaxException(this, UnexpectedCharacter, code);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void Parse_PathSegmentWithTypeNameNoNestedField_ThrowsSyntaxException()
// assert
Assert.Equal(
"Expected a `Period`-token, but found a `EndOfFile`-token.",
Assert.Throws<SyntaxException>(Act).Message);
Assert.Throws<FieldSelectionMapSyntaxException>(Act).Message);
}

[Fact]
Expand Down Expand Up @@ -101,7 +101,7 @@ public void Parse_PathWithTypeNameNoPathSegment_ThrowsSyntaxException()
// assert
Assert.Equal(
"Expected a `Period`-token, but found a `EndOfFile`-token.",
Assert.Throws<SyntaxException>(Act).Message);
Assert.Throws<FieldSelectionMapSyntaxException>(Act).Message);
}

[Fact]
Expand Down Expand Up @@ -143,7 +143,7 @@ public void Parse_SelectedListValueInvalidExamples_ThrowsSyntaxException(string
// assert
Assert.Equal(
"Expected a `RightSquareBracket`-token, but found a `Name`-token.",
Assert.Throws<SyntaxException>(Act).Message);
Assert.Throws<FieldSelectionMapSyntaxException>(Act).Message);
}

[Fact]
Expand Down Expand Up @@ -268,6 +268,6 @@ static void Act()
// assert
Assert.Equal(
"Source text contains more than 2 nodes. Parsing aborted.",
Assert.Throws<SyntaxException>(Act).Message);
Assert.Throws<FieldSelectionMapSyntaxException>(Act).Message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ static void Act()
// assert
Assert.Equal(
"Source text contains more than 2 tokens. Parsing aborted.",
Assert.Throws<SyntaxException>(Act).Message);
Assert.Throws<FieldSelectionMapSyntaxException>(Act).Message);
}

[Fact]
Expand All @@ -205,6 +205,6 @@ static void Act()
// assert
Assert.Equal(
"Unexpected character `*`.",
Assert.Throws<SyntaxException>(Act).Message);
Assert.Throws<FieldSelectionMapSyntaxException>(Act).Message);
}
}
Loading