IsConstraintError returns true if the error resulted from a database constraint violation.
(err error)
| 11 | |
| 12 | // IsConstraintError returns true if the error resulted from a database constraint violation. |
| 13 | func IsConstraintError(err error) bool { |
| 14 | var e *ConstraintError |
| 15 | return errors.As(err, &e) || |
| 16 | IsUniqueConstraintError(err) || |
| 17 | IsForeignKeyConstraintError(err) || |
| 18 | IsCheckConstraintError(err) |
| 19 | } |
| 20 | |
| 21 | // IsUniqueConstraintError reports if the error resulted from a DB uniqueness constraint violation. |
| 22 | // e.g. duplicate value in unique index. |
searching dependent graphs…