Skip to content

Commit

Permalink
Better error message
Browse files Browse the repository at this point in the history
  • Loading branch information
hknutzen committed Dec 18, 2023
1 parent 3ccd8c7 commit 00a5a14
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go/pkg/api/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func patchValue(a *ast.Attribute, c change) error {
}
if a.ComplexValue != nil {
if c.method == "add" {
return fmt.Errorf("Can't add to complex value of '%s'", a.Name)
return fmt.Errorf("Can't add duplicate definition of '%s'", a.Name)
}
return fmt.Errorf("Can't delete from complex value of '%s'", a.Name)
}
Expand Down
39 changes: 31 additions & 8 deletions go/testdata/api/path.t
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,6 @@ area:a2 = {
=INPUT=
network:n1 = { ip = 10.1.1.0/24; }
network:n2 = { ip = 10.1.2.0/24; }
network:n3 = { ip = 10.1.3.0/24; }
router:asa1 = {
managed;
Expand All @@ -779,13 +778,6 @@ router:asa1 = {
interface:n2 = { ip = 10.1.2.1; hardware = n2; }
}
router:asa2 = {
managed;
model = ASA;
interface:n2 = { ip = 10.1.2.2; hardware = n2; }
interface:n3 = { ip = 10.1.3.2; hardware = n3; }
}
area:a2 = {
inclusive_border = interface:asa1.n1;
}
Expand All @@ -809,4 +801,35 @@ Warning: Ignoring undefined owner:o1 of router_attributes of area:a2
+ }
inclusive_border = interface:asa1.n1;
}
=END=
############################################################
=TITLE=Add duplicate router_attributes
=INPUT=
owner:o1 = { admins = a1@example.com; }
network:n1 = { ip = 10.1.1.0/24; owner = o1; }
network:n2 = { ip = 10.1.2.0/24; }
router:asa1 = {
managed;
model = ASA;
interface:n1 = { ip = 10.1.1.1; hardware = n1; }
interface:n2 = { ip = 10.1.2.1; hardware = n2; }
}
area:a2 = {
router_attributes = { owner = o1; }
inclusive_border = interface:asa1.n1;
}
=JOB=
{
"method": "add",
"params": {
"path": "area:a2,router_attributes",
"value": { "owner": "o2" }
}
}
=ERROR=
Error: Can't add duplicate definition of 'router_attributes'
=END=
2 changes: 1 addition & 1 deletion go/testdata/api/topology.t
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ network:a = {
}
}
=ERROR=
Error: Can't add to complex value of 'host:name_10_1_1_4'
Error: Can't add duplicate definition of 'host:name_10_1_1_4'
=END=
############################################################
Expand Down

0 comments on commit 00a5a14

Please sign in to comment.