entc: return ErrNotFound on UpdateOne

Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/52

Reviewed By: alexsn

Differential Revision: D17737477

fbshipit-source-id: 13890619e0af28a28e3d7bd50d7e4287599eeaf0
This commit is contained in:
Ariel Mashraki
2019-10-03 06:22:49 -07:00
committed by Facebook Github Bot
parent 8b9e5cd7d0
commit 8e66691db5
41 changed files with 42 additions and 42 deletions

View File

@@ -282,7 +282,7 @@ func (guo *GroupUpdateOne) sqlSave(ctx context.Context) (gr *Group, err error) {
}
switch n := len(ids); {
case n == 0:
return nil, fmt.Errorf("ent: Group not found with id: %v", guo.id)
return nil, &ErrNotFound{fmt.Sprintf("Group with id: %v", guo.id)}
case n > 1:
return nil, fmt.Errorf("ent: more than one Group with the same id: %v", guo.id)
}

View File

@@ -326,7 +326,7 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (u *User, err error) {
}
switch n := len(ids); {
case n == 0:
return nil, fmt.Errorf("ent: User not found with id: %v", uuo.id)
return nil, &ErrNotFound{fmt.Sprintf("User with id: %v", uuo.id)}
case n > 1:
return nil, fmt.Errorf("ent: more than one User with the same id: %v", uuo.id)
}