mirror of
https://github.com/ent/ent.git
synced 2026-05-28 09:49:08 +03:00
all: use more go-ish error for constraint failures
This commit is contained in:
@@ -235,7 +235,7 @@ func (nu *NodeUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
return 0, rollback(tx, err)
|
||||
}
|
||||
if int(affected) < len(nu.prev) {
|
||||
return 0, rollback(tx, &ErrConstraintFailed{msg: fmt.Sprintf("one of \"prev\" %v already connected to a different \"Node\"", keys(nu.prev))})
|
||||
return 0, rollback(tx, &ConstraintError{msg: fmt.Sprintf("one of \"prev\" %v already connected to a different \"Node\"", keys(nu.prev))})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -266,7 +266,7 @@ func (nu *NodeUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
return 0, rollback(tx, err)
|
||||
}
|
||||
if int(affected) < len(nu.next) {
|
||||
return 0, rollback(tx, &ErrConstraintFailed{msg: fmt.Sprintf("one of \"next\" %v already connected to a different \"Node\"", keys(nu.next))})
|
||||
return 0, rollback(tx, &ConstraintError{msg: fmt.Sprintf("one of \"next\" %v already connected to a different \"Node\"", keys(nu.next))})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -495,7 +495,7 @@ func (nuo *NodeUpdateOne) sqlSave(ctx context.Context) (n *Node, err error) {
|
||||
return nil, rollback(tx, err)
|
||||
}
|
||||
if int(affected) < len(nuo.prev) {
|
||||
return nil, rollback(tx, &ErrConstraintFailed{msg: fmt.Sprintf("one of \"prev\" %v already connected to a different \"Node\"", keys(nuo.prev))})
|
||||
return nil, rollback(tx, &ConstraintError{msg: fmt.Sprintf("one of \"prev\" %v already connected to a different \"Node\"", keys(nuo.prev))})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -526,7 +526,7 @@ func (nuo *NodeUpdateOne) sqlSave(ctx context.Context) (n *Node, err error) {
|
||||
return nil, rollback(tx, err)
|
||||
}
|
||||
if int(affected) < len(nuo.next) {
|
||||
return nil, rollback(tx, &ErrConstraintFailed{msg: fmt.Sprintf("one of \"next\" %v already connected to a different \"Node\"", keys(nuo.next))})
|
||||
return nil, rollback(tx, &ConstraintError{msg: fmt.Sprintf("one of \"next\" %v already connected to a different \"Node\"", keys(nuo.next))})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user