Give packs an identity so create can refuse missing deps and load in a stable order.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-20 00:20:36 +03:00
co-authored by Cursor
parent e5a0ae5b9d
commit 263c94c55d
28 changed files with 851 additions and 56 deletions
@@ -0,0 +1,32 @@
namespace HSchool.Content;
/// <summary>
/// Selected packs cannot be ordered: a required pack is missing, or they require each other.
/// Distinct from <see cref="ContentLoadException"/> so the create dialog can name the pack.
/// </summary>
public sealed class PackDependencyException : Exception
{
public const string MissingCode = "missing-mod";
public const string CycleCode = "mod-cycle";
private PackDependencyException(string message, string code, string? missingPackId)
: base(message)
{
Code = code;
MissingPackId = missingPackId;
}
public string Code { get; }
public string? MissingPackId { get; }
public static PackDependencyException Missing(string missingPackId, string requiredBy) =>
new(
$"Pack '{requiredBy}' requires '{missingPackId}', which was not selected.",
MissingCode,
missingPackId);
public static PackDependencyException Cycle() =>
new("Selected packs have a cyclic dependency.", CycleCode, missingPackId: null);
}