lib/dag: improve dependency cycle error message

This commit is contained in:
Ching Pei Yang 2025-09-26 00:28:21 +02:00
commit 11fd1b7083
No known key found for this signature in database
GPG key ID: B3841364253DC4C8

View file

@ -8,7 +8,7 @@
# - the addition of the function `entryBefore` indicating a "wanted # - the addition of the function `entryBefore` indicating a "wanted
# by" relationship. # by" relationship.
{lib}: let {lib}: let
inherit (builtins) isAttrs attrValues attrNames elem all head tail length toJSON isString; inherit (builtins) isAttrs attrValues attrNames elem all head tail length toJSON isString removeAttrs;
inherit (lib.attrsets) filterAttrs mapAttrs; inherit (lib.attrsets) filterAttrs mapAttrs;
inherit (lib.lists) toposort; inherit (lib.lists) toposort;
inherit (lib.nvim.dag) empty isEntry entryBetween entryAfter entriesBetween entryAnywhere topoSort; inherit (lib.nvim.dag) empty isEntry entryBetween entryAfter entriesBetween entryAnywhere topoSort;
@ -169,10 +169,11 @@ in {
else value) else value)
dag; dag;
sortedDag = topoSort finalDag; sortedDag = topoSort finalDag;
loopDetail = map (loops: removeAttrs loops ["data"]) sortedDag.loops;
result = result =
if sortedDag ? result if sortedDag ? result
then mapResult sortedDag.result then mapResult sortedDag.result
else abort ("Dependency cycle in ${name}: " + toJSON sortedDag); else abort ("Dependency cycle in ${name}: " + toJSON loopDetail);
in in
result; result;
} }