From ff57e5180a1f78e8f409791305182f52abf55faf Mon Sep 17 00:00:00 2001 From: James Mitchell Date: Sat, 3 Oct 2026 19:36:22 +0100 Subject: [PATCH] Move error from gv -> dot --- gap/dot.gi | 14 +++++++------- gap/gv.gi | 4 +--- tst/node.tst | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/gap/dot.gi b/gap/dot.gi index 0997734..403d3db 100644 --- a/gap/dot.gi +++ b/gap/dot.gi @@ -294,10 +294,15 @@ InstallMethod(GraphvizGetAttr, "for a graphviz (di)graph or context and string", # GraphvizAddNode ############################################################################# -InstallMethod(GraphvizAddNode, "for a graphviz (di)graph or context and string", -[IsGraphvizGraphDigraphOrContext, IsString], +InstallMethod(GraphvizAddNode, "for a graphviz (di)graph or context and object", +[IsGraphvizGraphDigraphOrContext, IsObject], function(gv, val) local node; + val := String(val); + + if Length(val) = 0 then + ErrorNoReturn("the argument (the name of the node being added) cannot be empty"); + fi; # Reuse existing node if available node := GraphvizNode(gv, val); @@ -332,11 +337,6 @@ function(gv, name) # gaplint: disable=unused-func-args "the node's name instead"); end); -InstallMethod(GraphvizAddNode, -"for a graphviz (di)graph or context and string", -[IsGraphvizGraphDigraphOrContext, IsObject], -{x, name} -> GraphvizAddNode(x, String(name))); - ############################################################################# # GraphvizAddEdge ############################################################################# diff --git a/gap/gv.gi b/gap/gv.gi index 9db9dd4..fe12654 100644 --- a/gap/gv.gi +++ b/gap/gv.gi @@ -35,9 +35,7 @@ InstallMethod(GV_Node, "for a string", [IsGraphvizGraphDigraphOrContext, IsString], function(graph, name) local out; - if Length(name) = 0 then - ErrorNoReturn("the 2nd argument (string/node name) cannot be empty"); - fi; + Assert(0, not IsEmpty(name)); out := Objectify(GV_NodeType, rec( Name := name, diff --git a/tst/node.tst b/tst/node.tst index 0df86ab..3d9b9d3 100644 --- a/tst/node.tst +++ b/tst/node.tst @@ -28,7 +28,7 @@ gap> n := GraphvizAddNode(GraphvizGraph(), " "); # Test making a node with empty name fails gap> n := GraphvizAddNode(GraphvizGraph(), ""); -Error, the 2nd argument (string/node name) cannot be empty +Error, the argument (the name of the node being added) cannot be empty # Test whitespace in node names gap> n := GraphvizAddNode(GraphvizGraph(), "a a ");