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:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user