using System.Text.Json.Serialization; namespace AIStudio.Tools; // ReSharper disable UnusedAutoPropertyAccessor.Global // ReSharper disable ClassNeverInstantiated.Global public sealed class ContentStreamErrorDetails { [JsonPropertyName("code")] public string? Code { get; init; } [JsonPropertyName("message")] public string? Message { get; init; } /// /// The page the failure belongs to, when the failure affects a single page only. /// [JsonPropertyName("page_number")] public int? PageNumber { get; init; } /// /// Gets the parsed error code. /// /// /// Codes this version does not know map to /// instead of failing the deserialization. A failed deserialization would turn the reported /// error back into empty file content, which is exactly what we want to avoid here. /// [JsonIgnore] public FileExtractionErrorCode ParsedCode => Enum.TryParse(this.Code, ignoreCase: true, out var parsedCode) ? parsedCode : FileExtractionErrorCode.UNKNOWN; /// /// Gets a value indicating whether this failure affects one part of the file only, while the /// remaining content is still usable. /// [JsonIgnore] public bool IsPartialFailure => this.ParsedCode is FileExtractionErrorCode.PAGE_EXTRACTION_FAILED; }