Files
av-parser/src/AvParser.Core/Parsing/ParseError.cs
T
Leonid Pershin eb5061ee23 Refactor media source handling and update collection options
- Updated `IMediaSourceCatalog` to support user-added media sources, allowing dynamic editing and management of sources.
- Removed the `UrlListSource` class as its functionality is now integrated into the new catalog structure.
- Enhanced `CollectOptions` to default `RequireProxy` to true, ensuring stricter handling of proxy requirements.
- Improved error handling in `ParseError` to include a `Subject` field for better context on failures.
- Adjusted dependency injection to reflect changes in media source management, removing old source registrations.
- Introduced background proxy checks to ensure a more robust proxy pool management during collection processes.

These changes streamline the media collection process and improve the overall user experience by providing clearer error reporting and more flexible source management.
2026-08-15 14:20:06 +03:00

39 lines
2.0 KiB
C#

namespace AvParser.Core.Parsing;
/// <summary>A recoverable problem with a single record. Parsing continues after one of these.</summary>
/// <param name="Index">1-based position of the offending item: a line, or a place in a listing.</param>
/// <param name="Message">What went wrong, phrased for a user rather than a developer.</param>
public sealed record ParseError(int Index, string Message)
{
/// <summary>
/// Stable identifier for the kind of failure, or <see langword="null"/> when the message is
/// the only thing on offer.
/// </summary>
/// <remarks>
/// The domain stays language-free: it produces an English message plus a code, and the UI
/// translates <c>Collect.Error.{Code}</c> with <see cref="Arguments"/>, falling back to
/// <see cref="Message"/>. Without this, a Russian UI would still print English error text —
/// and moving the strings themselves into the domain would drag localisation down there.
/// </remarks>
public string? Code { get; init; }
/// <summary>Values to substitute into the translated message.</summary>
public IReadOnlyList<object?> Arguments { get; init; } = [];
/// <summary>What the failure was about — the address or the line it came from.</summary>
/// <remarks>
/// Deliberately outside <see cref="Message"/> and <see cref="Arguments"/>: a translated template
/// has fixed placeholders, so an address cannot be appended to it without editing every
/// translation. The live collection log prints this beside the translated text, which is the
/// difference between "the site answered 404" and knowing which of ten thousand ids that was.
/// </remarks>
public string? Subject { get; init; }
/// <summary>Creates an error carrying a translation code.</summary>
public static ParseError Create(int index, string code, string message, params object?[] arguments) =>
new(index, message) { Code = code, Arguments = arguments };
/// <inheritdoc />
public override string ToString() => $"#{Index}: {Message}";
}