Skip to content

Commit

Permalink
Fix an oversight where the original exception message would get repla…
Browse files Browse the repository at this point in the history
…ced by this other one in many cases.
  • Loading branch information
airbreather committed Apr 15, 2024
1 parent 0721747 commit 68b0bb1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/NetTopologySuite.IO.GeoJSON4STJ/Converters/Utility.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Buffers;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
Expand Down Expand Up @@ -93,6 +95,13 @@ private static void ThrowForUnexpectedEndOfStream()

[MethodImpl(MethodImplOptions.NoInlining)]
private static void ThrowForUnexpectedToken(JsonTokenType requiredNextTokenType, ref Utf8JsonReader reader)
=> throw new JsonException(string.Format(Resources.EX_UnexpectedToken, requiredNextTokenType, reader.TokenType, reader.GetString()));
=> throw new JsonException(string.Format(Resources.EX_UnexpectedToken, requiredNextTokenType, reader.TokenType, CurrentTokenAsString(in reader)));

private static string CurrentTokenAsString(in Utf8JsonReader reader)
{
return Encoding.UTF8.GetString(reader.HasValueSequence
? reader.ValueSequence.ToArray()
: reader.ValueSpan.ToArray());
}
}
}

0 comments on commit 68b0bb1

Please sign in to comment.