Skip to content

Commit

Permalink
Improve error message
Browse files Browse the repository at this point in the history
  • Loading branch information
oanatmaria committed Oct 26, 2023
1 parent e8acb04 commit 2093ac0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions model/diff/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ func (d *Diff) validateObjectTypes(objs []string, rels []*RelationKind) error {
for _, objType := range d.Removed.Objects {
_, found := lo.Find(objs, func(obj string) bool { return obj == objType })
if found {
errs = multierror.Append(errs, errors.Wrapf(derr.ErrObjectTypeInUse, "object type: %s", objType))
errs = multierror.Append(errs, errors.Wrapf(derr.ErrObjectTypeInUse, "object type [%s]", objType))
}
_, found = lo.Find(rels, func(rel *RelationKind) bool { return rel.Object == objType || rel.Subject == objType })
rel, found := lo.Find(rels, func(rel *RelationKind) bool { return rel.Object == objType || rel.Subject == objType })
if found {
errs = multierror.Append(errs, errors.Wrapf(derr.ErrObjectTypeInUse, "object type: %s", objType))
errs = multierror.Append(errs, errors.Wrapf(derr.ErrRelationTypeInUse, "object type [%s], relation type [%s]", objType, rel.Relation))
}
}
return errs
Expand All @@ -93,7 +93,7 @@ func (d *Diff) validateRelationsTypes(relations []*RelationKind) error {
return rl.Object == objType && rl.Relation == rel
})
if found {
errs = multierror.Append(errs, errors.Wrapf(derr.ErrRelationTypeInUse, "object type: %s", objType))
errs = multierror.Append(errs, errors.Wrapf(derr.ErrRelationTypeInUse, "object type [%s], relation type [%s]", objType, rel))
}
}
}
Expand Down

0 comments on commit 2093ac0

Please sign in to comment.