From 2093ac0a1d3bb40271de20c5827e9676cc67d891 Mon Sep 17 00:00:00 2001 From: oanatmaria Date: Thu, 26 Oct 2023 12:17:59 +0300 Subject: [PATCH] Improve error message --- model/diff/diff.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/model/diff/diff.go b/model/diff/diff.go index 55fec83..c13d48a 100644 --- a/model/diff/diff.go +++ b/model/diff/diff.go @@ -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 @@ -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)) } } }