<PackageReference Include="System.Text.Json" Version="9.0.10" />

JsonException

public class JsonException : Exception
Defines a custom exception object that is thrown when invalid JSON text is encountered, the defined maximum depth is passed, or the JSON text is not compatible with the type of a property on an object.
using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.Serialization; namespace System.Text.Json { [Serializable] [NullableContext(2)] [Nullable(0)] public class JsonException : Exception { internal string _message; internal bool AppendPathInformation { get; set; } public long? LineNumber { get; set; } public long? BytePositionInLine { get; set; } public string Path { get; set; } [Nullable(1)] public override string Message { [NullableContext(1)] get { return _message ?? base.Message; } } public JsonException(string message, string path, long? lineNumber, long? bytePositionInLine, Exception innerException) : base(message, innerException) { _message = message; LineNumber = lineNumber; BytePositionInLine = bytePositionInLine; Path = path; } public JsonException(string message, string path, long? lineNumber, long? bytePositionInLine) : base(message) { _message = message; LineNumber = lineNumber; BytePositionInLine = bytePositionInLine; Path = path; } public JsonException(string message, Exception innerException) : base(message, innerException) { _message = message; } public JsonException(string message) : base(message) { _message = message; } public JsonException() { } [NullableContext(1)] [Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [EditorBrowsable(EditorBrowsableState.Never)] protected JsonException(SerializationInfo info, StreamingContext context) : base(info, context) { LineNumber = (long?)info.GetValue("LineNumber", typeof(long?)); BytePositionInLine = (long?)info.GetValue("BytePositionInLine", typeof(long?)); Path = info.GetString("Path"); SetMessage(info.GetString("ActualMessage")); } [NullableContext(1)] [Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); info.AddValue("LineNumber", LineNumber, typeof(long?)); info.AddValue("BytePositionInLine", BytePositionInLine, typeof(long?)); info.AddValue("Path", Path, typeof(string)); info.AddValue("ActualMessage", Message, typeof(string)); } internal void SetMessage(string message) { _message = message; } } }