all: use more go-ish error for constraint failures

This commit is contained in:
Ariel Mashraki
2019-12-17 22:55:33 +02:00
parent c6800a3869
commit 798d58f02b
78 changed files with 422 additions and 440 deletions

View File

@@ -6,7 +6,7 @@ in the LICENSE file in the root directory of this source tree.
{{/* custom errors and errors handlers for sql dialects */}}
{{ define "dialect/sql/errors" }}
func isSQLConstraintError(err error) (*ErrConstraintFailed, bool) {
func isSQLConstraintError(err error) (*ConstraintError, bool) {
var (
msg = err.Error()
// error format per dialect.
@@ -17,11 +17,11 @@ func isSQLConstraintError(err error) (*ErrConstraintFailed, bool) {
}
)
if _, ok := err.(*sqlgraph.ConstraintError); ok {
return &ErrConstraintFailed{msg, err}, true
return &ConstraintError{msg, err}, true
}
for i := range errors {
if strings.Contains(msg, errors[i]) {
return &ErrConstraintFailed{msg, err}, true
return &ConstraintError{msg, err}, true
}
}
return nil, false